feat(build): create_tables.py 幂等迁移 pipeline_human_tasks 项目/迭代/bug/QC 字段
This commit is contained in:
parent
cde7293d5e
commit
25e9900193
@ -264,6 +264,38 @@ async def main():
|
||||
except Exception as e:
|
||||
print(f' WARN: pipeline_agent_questions migrate failed: {e}')
|
||||
|
||||
# pipeline_human_tasks SDLC 项目级人类任务列迁移(项目/迭代/bug 归属 + QC + bug 验收)
|
||||
try:
|
||||
_pht_cols = {
|
||||
"project_id": "VARCHAR(32) NULL COMMENT '项目ID'",
|
||||
"iteration_id": "VARCHAR(32) NULL COMMENT '迭代ID'",
|
||||
"bug_id": "VARCHAR(32) NULL COMMENT '关联BugID'",
|
||||
"qc_status": "VARCHAR(20) NULL DEFAULT 'pending' COMMENT 'QC状态'",
|
||||
"qc_comment": "VARCHAR(500) NULL COMMENT 'QC意见'",
|
||||
}
|
||||
for col, ddl in _pht_cols.items():
|
||||
r = await sor.sqlExe(
|
||||
"SELECT COUNT(*) as c FROM information_schema.COLUMNS "
|
||||
"WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pipeline_human_tasks' "
|
||||
"AND COLUMN_NAME=${col}$", {"col": col})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
if not r or getattr(r[0], 'c', 0) == 0:
|
||||
await sor.execute(
|
||||
f"ALTER TABLE pipeline_human_tasks ADD COLUMN {col} {ddl}", {})
|
||||
for idx_name, idx_col in [("pipeline_human_tasks_idx_pht_project", "project_id"),
|
||||
("pipeline_human_tasks_idx_pht_iteration", "iteration_id")]:
|
||||
r = await sor.sqlExe(
|
||||
"SELECT COUNT(*) as c FROM information_schema.STATISTICS "
|
||||
"WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pipeline_human_tasks' "
|
||||
"AND INDEX_NAME=${idx}$", {"idx": idx_name})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
if not r or getattr(r[0], 'c', 0) == 0:
|
||||
await sor.execute(
|
||||
f"CREATE INDEX {idx_name} ON pipeline_human_tasks({idx_col})", {})
|
||||
print(' migrate: pipeline_human_tasks project/iteration/bug/qc columns ensured')
|
||||
except Exception as e:
|
||||
print(f' WARN: pipeline_human_tasks migrate failed: {e}')
|
||||
|
||||
# sd_features 功能/需求表(pipeline-sdlc 业务表)幂等建表——手写 DDL 避开 json2ddl 的 DEFAULT ''N'' bug
|
||||
try:
|
||||
await sor.execute(_SD_FEATURES_DDL, {})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user