forked from cartsnitch/api
cd58401411
- Add PostgreSQL JSONB containment (@>) query for match_by_upc - Add SQLite LIKE fallback for test compatibility - Update upc_variants column to JSONB with variant for cross-db support - Add GIN index migration for upc_variants Co-Authored-By: Paperclip <noreply@paperclip.ing>
39 lines
939 B
Python
39 lines
939 B
Python
"""Add GIN index on upc_variants and alter column to JSONB.
|
|
|
|
Revision ID: 009_add_gin_index_upc_variants
|
|
Revises: 008_create_domain_tables
|
|
Create Date: 2026-04-14
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "009_add_gin_index_upc_variants"
|
|
down_revision = "008_create_domain_tables"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.alter_column(
|
|
"normalized_products",
|
|
"upc_variants",
|
|
type_=sa.dialects.postgresql.JSONB(),
|
|
postgresql_using="upc_variants::jsonb",
|
|
)
|
|
op.create_index(
|
|
"ix_normalized_products_upc_variants_gin",
|
|
"normalized_products",
|
|
["upc_variants"],
|
|
postgresql_using="gin",
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_normalized_products_upc_variants_gin", table_name="normalized_products")
|
|
op.alter_column(
|
|
"normalized_products",
|
|
"upc_variants",
|
|
type_=sa.JSON(),
|
|
)
|