docs(migrate): 为导出相关表添加中文注释说明

This commit is contained in:
zhouyonggao 2025-11-24 17:47:19 +08:00
parent 20aa051af4
commit dde8bdb05f
1 changed files with 60 additions and 0 deletions

View File

@ -16,5 +16,65 @@ func Apply(db *sql.DB) error {
return err
}
}
comments := []string{
"ALTER TABLE export_templates COMMENT='导出模板主表'",
"ALTER TABLE export_templates MODIFY id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '主键ID'",
"ALTER TABLE export_templates MODIFY name VARCHAR(255) NOT NULL COMMENT '模板名称'",
"ALTER TABLE export_templates MODIFY datasource VARCHAR(32) NOT NULL COMMENT '数据源标识'",
"ALTER TABLE export_templates MODIFY main_table VARCHAR(64) NOT NULL COMMENT '主表名'",
"ALTER TABLE export_templates MODIFY joins_json JSON COMMENT '关联表定义'",
"ALTER TABLE export_templates MODIFY fields_json JSON COMMENT '字段选择'",
"ALTER TABLE export_templates MODIFY filters_json JSON COMMENT '过滤条件'",
"ALTER TABLE export_templates MODIFY file_format VARCHAR(16) NOT NULL COMMENT '文件格式'",
"ALTER TABLE export_templates MODIFY stats_enabled TINYINT(1) NOT NULL COMMENT '统计开关'",
"ALTER TABLE export_templates MODIFY sheet_split_by VARCHAR(64) COMMENT '多sheet拆分条件'",
"ALTER TABLE export_templates MODIFY visibility VARCHAR(16) NOT NULL COMMENT '可见性'",
"ALTER TABLE export_templates MODIFY owner_id BIGINT UNSIGNED NOT NULL COMMENT '所有者ID'",
"ALTER TABLE export_templates MODIFY enabled TINYINT(1) NOT NULL COMMENT '启用状态'",
"ALTER TABLE export_templates MODIFY explain_json JSON COMMENT 'EXPLAIN结果'",
"ALTER TABLE export_templates MODIFY explain_score INT COMMENT 'EXPLAIN评分'",
"ALTER TABLE export_templates MODIFY last_validated_at DATETIME COMMENT '最近校验时间'",
"ALTER TABLE export_templates MODIFY created_at DATETIME NOT NULL COMMENT '创建时间'",
"ALTER TABLE export_templates MODIFY updated_at DATETIME NOT NULL COMMENT '更新时间'",
"ALTER TABLE export_jobs COMMENT='导出任务表'",
"ALTER TABLE export_jobs MODIFY id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '主键ID'",
"ALTER TABLE export_jobs MODIFY template_id BIGINT UNSIGNED NOT NULL COMMENT '模板ID'",
"ALTER TABLE export_jobs MODIFY status VARCHAR(16) NOT NULL COMMENT '任务状态'",
"ALTER TABLE export_jobs MODIFY requested_by BIGINT UNSIGNED NOT NULL COMMENT '请求人ID'",
"ALTER TABLE export_jobs MODIFY permission_scope_json JSON COMMENT '权限范围'",
"ALTER TABLE export_jobs MODIFY options_json JSON COMMENT '执行选项'",
"ALTER TABLE export_jobs MODIFY row_estimate BIGINT COMMENT '行数估算'",
"ALTER TABLE export_jobs MODIFY total_rows BIGINT COMMENT '实际行数'",
"ALTER TABLE export_jobs MODIFY file_format VARCHAR(16) NOT NULL COMMENT '文件格式'",
"ALTER TABLE export_jobs MODIFY started_at DATETIME COMMENT '开始时间'",
"ALTER TABLE export_jobs MODIFY finished_at DATETIME COMMENT '完成时间'",
"ALTER TABLE export_jobs MODIFY created_at DATETIME NOT NULL COMMENT '创建时间'",
"ALTER TABLE export_jobs MODIFY updated_at DATETIME NOT NULL COMMENT '更新时间'",
"ALTER TABLE export_job_files COMMENT='导出文件记录'",
"ALTER TABLE export_job_files MODIFY id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '主键ID'",
"ALTER TABLE export_job_files MODIFY job_id BIGINT UNSIGNED NOT NULL COMMENT '任务ID'",
"ALTER TABLE export_job_files MODIFY storage_uri VARCHAR(1024) NOT NULL COMMENT '存储地址'",
"ALTER TABLE export_job_files MODIFY sheet_name VARCHAR(255) COMMENT 'sheet名称'",
"ALTER TABLE export_job_files MODIFY row_count BIGINT COMMENT '行数'",
"ALTER TABLE export_job_files MODIFY size_bytes BIGINT COMMENT '文件大小'",
"ALTER TABLE export_job_files MODIFY checksum VARCHAR(128) COMMENT '校验值'",
"ALTER TABLE export_job_files MODIFY created_at DATETIME NOT NULL COMMENT '创建时间'",
"ALTER TABLE export_audits COMMENT='审计与变更记录'",
"ALTER TABLE export_audits MODIFY id BIGINT UNSIGNED AUTO_INCREMENT COMMENT '主键ID'",
"ALTER TABLE export_audits MODIFY actor_id BIGINT UNSIGNED NOT NULL COMMENT '操作者ID'",
"ALTER TABLE export_audits MODIFY action VARCHAR(64) NOT NULL COMMENT '动作'",
"ALTER TABLE export_audits MODIFY entity_type VARCHAR(64) NOT NULL COMMENT '对象类型'",
"ALTER TABLE export_audits MODIFY entity_id BIGINT UNSIGNED NOT NULL COMMENT '对象ID'",
"ALTER TABLE export_audits MODIFY detail_json JSON COMMENT '详情'",
"ALTER TABLE export_audits MODIFY created_at DATETIME NOT NULL COMMENT '创建时间'",
}
for _, s := range comments {
if _, err := db.Exec(s); err != nil {
return err
}
}
return nil
}