feat: create_tables.py 幂等建 sd_features 表(手写DDL避开json2ddl的DEFAULT ''N'' bug)
This commit is contained in:
parent
0acdb1fc19
commit
a416d794ac
@ -38,6 +38,29 @@ _PARAMS_INIT = [
|
||||
("workspace_base", "/d/pipeline/workspaces"),
|
||||
]
|
||||
|
||||
# sd_features 功能/需求表 DDL(手写,避开 json2ddl 的 DEFAULT ''N'' bug;索引内联避免重复建 Duplicate key name)
|
||||
_SD_FEATURES_DDL = """
|
||||
CREATE TABLE IF NOT EXISTS sd_features (
|
||||
`id` VARCHAR(32) NOT NULL comment '主键ID',
|
||||
`project_id` VARCHAR(32) NOT NULL comment '项目ID',
|
||||
`iteration_id` VARCHAR(32) comment '迭代ID',
|
||||
`feature_name` VARCHAR(200) NOT NULL comment '功能名称',
|
||||
`description` text comment '功能描述',
|
||||
`feature_type` VARCHAR(20) NOT NULL DEFAULT 'new_feature' comment '功能类型',
|
||||
`priority` VARCHAR(10) NOT NULL DEFAULT 'P2' comment '优先级',
|
||||
`status` VARCHAR(20) NOT NULL DEFAULT 'proposed' comment '功能状态',
|
||||
`acceptance_criteria` text comment '验收标准',
|
||||
`task_id` VARCHAR(32) comment '关联Pipeline任务ID',
|
||||
`created_by` VARCHAR(32) comment '创建人',
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL comment '创建时间',
|
||||
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间',
|
||||
primary key(id),
|
||||
KEY idx_sd_features_project(project_id),
|
||||
KEY idx_sd_features_iteration(iteration_id),
|
||||
KEY idx_sd_features_status(status)
|
||||
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci engine=innodb comment '功能/需求表';
|
||||
"""
|
||||
|
||||
|
||||
def split_ddl(ddl):
|
||||
"""按分号分割 DDL,跳过注释行和空语句。"""
|
||||
@ -141,6 +164,13 @@ async def main():
|
||||
except Exception as e:
|
||||
print(f' WARN: pipeline_agent_questions migrate failed: {e}')
|
||||
|
||||
# sd_features 功能/需求表(pipeline-sdlc 业务表)幂等建表——手写 DDL 避开 json2ddl 的 DEFAULT ''N'' bug
|
||||
try:
|
||||
await sor.execute(_SD_FEATURES_DDL, {})
|
||||
print(' tables: sd_features ensured (idempotent)')
|
||||
except Exception as e:
|
||||
print(f' WARN: sd_features ensure failed: {e}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user