46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""
|
|
添加指标表的 bs_dimension 字段
|
|
"""
|
|
import asyncio
|
|
from sqlalchemy import text
|
|
from app.core.database import engine
|
|
|
|
|
|
async def migrate():
|
|
"""添加 bs_dimension 字段到 indicators 表"""
|
|
async with engine.begin() as conn:
|
|
# 添加 bs_dimension 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN bs_dimension VARCHAR(50) NOT NULL DEFAULT 'internal_process'")
|
|
)
|
|
# 添加 target_unit 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN target_unit VARCHAR(50)")
|
|
)
|
|
# 添加 assessment_method 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN assessment_method TEXT")
|
|
)
|
|
# 添加 deduction_standard 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN deduction_standard TEXT")
|
|
)
|
|
# 添加 data_source 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN data_source VARCHAR(100)")
|
|
)
|
|
# 添加 applicable_dept_types 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN applicable_dept_types TEXT")
|
|
)
|
|
# 添加 is_veto 字段
|
|
await conn.execute(
|
|
text("ALTER TABLE indicators ADD COLUMN is_veto BOOLEAN NOT NULL DEFAULT 0")
|
|
)
|
|
|
|
print("指标表迁移完成!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(migrate())
|