from alembic import op import sqlalchemy as sa revision = '20251107_add_missing_indexes' down_revision = '1a1f1f1fc71c' # Adjust if needed to match your current head depends_on = None branch_labels = None def upgrade() -> None: # Index for sorting by price op.create_index("ix_products_regular_price", "products", ["regular_price"]) # Index for filtering/aggregating by brand op.create_index("ix_products_brand", "products", ["brand"]) # Index for product_likes.product_id (if not already covered by FK) op.create_index("ix_product_likes_product_id", "product_likes", ["product_id"]) # Composite index on listing_items (may be partially redundant with existing constraints) op.create_index("ix_listing_items_listing_slug", "listing_items", ["listing_id", "slug"]) def downgrade() -> None: op.drop_index("ix_listing_items_listing_slug", table_name="listing_items") op.drop_index("ix_product_likes_product_id", table_name="product_likes") op.drop_index("ix_products_brand", table_name="products") op.drop_index("ix_products_regular_price", table_name="products")