| 12345678910111213141516171819202122232425262728293031323334 |
- """创建 Analytics 库基础表。"""
- from alembic import op
- from app.infrastructure.mysql.analytics_models import AnalyticsBase
- revision = "analytics_0001"
- down_revision = None
- branch_labels = None
- depends_on = None
- TABLE_NAMES = (
- "dim_date",
- "dim_product",
- "dim_salesperson",
- "fact_orders",
- "fact_policies",
- "metric_definitions",
- "analytics_sync_offsets",
- )
- def upgrade() -> None:
- bind = op.get_bind()
- for table in AnalyticsBase.metadata.sorted_tables:
- if table.name in TABLE_NAMES:
- table.create(bind=bind)
- def downgrade() -> None:
- bind = op.get_bind()
- for table in reversed(AnalyticsBase.metadata.sorted_tables):
- if table.name in TABLE_NAMES:
- table.drop(bind=bind)
|