- 移除后端产品、目的地、活动专题等废弃模块的数据库表与业务代码,删除冗余API接口 - 删除小程序端详情页、线路组件等冗余代码,移除搜索工具与测试用例,调整导航逻辑 - 清理管理端废弃的类型定义、编辑器与测试代码 - 更新项目文档,修正模块维护说明与接口文档内容
58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
"""Remove the retired product domain and its foreign-key references.
|
|
|
|
Revision ID: 0009_remove_product_domain
|
|
Revises: 0008_demand_page_modules
|
|
Create Date: 2026-08-17
|
|
"""
|
|
|
|
from alembic import op
|
|
from sqlalchemy import inspect
|
|
|
|
|
|
revision = "0009_remove_product_domain"
|
|
down_revision = "0008_demand_page_modules"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
PRODUCT_TABLES = (
|
|
"CampaignProduct",
|
|
"RouteSectionProduct",
|
|
"DemandRecommendationProduct",
|
|
"ProductImage",
|
|
"Product",
|
|
)
|
|
|
|
|
|
def _drop_column_with_foreign_keys(table_name: str, column_name: str) -> None:
|
|
bind = op.get_bind()
|
|
inspector = inspect(bind)
|
|
if table_name not in inspector.get_table_names():
|
|
return
|
|
columns = {column["name"] for column in inspector.get_columns(table_name)}
|
|
if column_name not in columns:
|
|
return
|
|
for foreign_key in inspector.get_foreign_keys(table_name):
|
|
if column_name in foreign_key.get("constrained_columns", []):
|
|
constraint_name = foreign_key.get("name")
|
|
if constraint_name:
|
|
op.drop_constraint(constraint_name, table_name, type_="foreignkey")
|
|
op.drop_column(table_name, column_name)
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
existing_tables = set(inspect(bind).get_table_names())
|
|
|
|
_drop_column_with_foreign_keys("Lead", "sourceProductId")
|
|
_drop_column_with_foreign_keys("Order", "productId")
|
|
|
|
for table_name in (*PRODUCT_TABLES[:3], "RouteSection", "DemandRecommendation", *PRODUCT_TABLES[3:]):
|
|
if table_name in existing_tables:
|
|
op.drop_table(table_name)
|
|
|
|
|
|
def downgrade() -> None:
|
|
# The retired product schema intentionally has no downgrade path. Restore it from a backup if needed.
|
|
pass
|