"""Remove the retired province destination module. Revision ID: 0010_remove_destination_module Revises: 0009_remove_product_domain Create Date: 2026-08-17 """ from alembic import op from sqlalchemy import inspect revision = "0010_remove_destination_module" down_revision = "0009_remove_product_domain" branch_labels = None depends_on = None def _drop_referencing_foreign_keys(table_name: str) -> None: bind = op.get_bind() inspector = inspect(bind) for current_table in inspector.get_table_names(): if current_table == table_name: continue for foreign_key in inspector.get_foreign_keys(current_table): if foreign_key.get("referred_table") != table_name: continue constraint_name = foreign_key.get("name") if constraint_name: op.drop_constraint(constraint_name, current_table, type_="foreignkey") def upgrade() -> None: bind = op.get_bind() existing_tables = set(inspect(bind).get_table_names()) for table_name in ("DestinationAlias", "Destination"): if table_name not in existing_tables: continue _drop_referencing_foreign_keys(table_name) op.drop_table(table_name) def downgrade() -> None: # The retired destination module has no downgrade path. Restore it from a backup if needed. pass