23 lines
635 B
Python
23 lines
635 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from sqlalchemy.engine import Connection, Engine
|
||
|
|
|
||
|
|
from app.db.base import Base
|
||
|
|
|
||
|
|
MIGRATION_OWNED_TABLES: frozenset[str] = frozenset(
|
||
|
|
{
|
||
|
|
"auth_sessions",
|
||
|
|
"expense_cases",
|
||
|
|
"expense_case_links",
|
||
|
|
"business_events",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def create_legacy_schema(bind: Engine | Connection) -> None:
|
||
|
|
"""创建仍由旧 bootstrap 管理的表,不越过 Alembic 的表所有权边界。"""
|
||
|
|
legacy_tables = [
|
||
|
|
table for table in Base.metadata.sorted_tables if table.name not in MIGRATION_OWNED_TABLES
|
||
|
|
]
|
||
|
|
Base.metadata.create_all(bind=bind, tables=legacy_tables)
|