Newer
Older
vmk-360-data_collector / alembic / versions / ce83ed173113_add_performance_indexes.py
@Eugene Sukhodolskiy Eugene Sukhodolskiy 1 day ago 3 KB feat: implement review items 1-7
"""add_performance_indexes

Revision ID: ce83ed173113
Revises: 33cad32b9bbd
Create Date: 2026-06-12 02:37:35.289353

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'ce83ed173113'
down_revision: Union[str, Sequence[str], None] = '33cad32b9bbd'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index('ix_ai_enrichments_property_id', 'ai_enrichments', ['property_id'], unique=False)
    op.create_index('ix_property_custom_fields_property_id', 'property_custom_fields', ['property_id'], unique=False)
    op.create_index('ix_property_images_hash', 'property_images', ['hash'], unique=False)
    op.create_index('ix_property_images_property_id', 'property_images', ['property_id'], unique=False)
    op.create_index('ix_property_listings_city', 'property_listings', ['city'], unique=False)
    op.create_index('ix_property_listings_deal_type', 'property_listings', ['deal_type'], unique=False)
    op.create_index('ix_property_listings_external_id', 'property_listings', ['external_id'], unique=False)
    op.create_index('ix_property_listings_listing_status', 'property_listings', ['listing_status'], unique=False)
    op.create_index('ix_property_listings_price', 'property_listings', ['price'], unique=False)
    op.create_index('ix_property_listings_property_type_id', 'property_listings', ['property_type_id'], unique=False)
    op.create_index('ix_property_listings_source_id', 'property_listings', ['source_id'], unique=False)
    op.create_index('ix_property_snapshots_property_id', 'property_snapshots', ['property_id'], unique=False)
    op.create_index('ix_raw_parsing_data_external_id', 'raw_parsing_data', ['external_id'], unique=False)
    op.create_index('ix_raw_parsing_data_source_id', 'raw_parsing_data', ['source_id'], unique=False)
    op.create_index('ix_raw_parsing_data_status', 'raw_parsing_data', ['status'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_raw_parsing_data_status', table_name='raw_parsing_data')
    op.drop_index('ix_raw_parsing_data_source_id', table_name='raw_parsing_data')
    op.drop_index('ix_raw_parsing_data_external_id', table_name='raw_parsing_data')
    op.drop_index('ix_property_snapshots_property_id', table_name='property_snapshots')
    op.drop_index('ix_property_listings_source_id', table_name='property_listings')
    op.drop_index('ix_property_listings_property_type_id', table_name='property_listings')
    op.drop_index('ix_property_listings_price', table_name='property_listings')
    op.drop_index('ix_property_listings_listing_status', table_name='property_listings')
    op.drop_index('ix_property_listings_external_id', table_name='property_listings')
    op.drop_index('ix_property_listings_deal_type', table_name='property_listings')
    op.drop_index('ix_property_listings_city', table_name='property_listings')
    op.drop_index('ix_property_images_property_id', table_name='property_images')
    op.drop_index('ix_property_images_hash', table_name='property_images')
    op.drop_index('ix_property_custom_fields_property_id', table_name='property_custom_fields')
    op.drop_index('ix_ai_enrichments_property_id', table_name='ai_enrichments')
    # ### end Alembic commands ###