Files
dpb/_validate_tables.py
T

26 lines
734 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""验证 bre 全部模型可成功建表(不触发重复索引/DuplicateTableError)。"""
import asyncio
import os
import sys
os.environ["ENVIRONMENT"] = "dev"
sys.path.insert(0, "d:/dpb/dpb/backend")
from app.api.v1.module_bre import bre_router # noqa: F401 触发模型注册
from app.core.base_model import MappedBase # noqa: E402
from app.core.database import create_tables # noqa: E402
async def main():
await create_tables()
tables = sorted(t for t in MappedBase.metadata.tables.keys() if t.startswith("bre_"))
print("CREATE_TABLES_OK")
print("bre tables count =", len(tables))
for t in tables:
print(" -", t)
if __name__ == "__main__":
asyncio.run(main())