
-- models/pipeline_versions.json





-- 建库时请用以下语句，支持emoji字符
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
drop table if exists pipeline_versions;
CREATE TABLE pipeline_versions
(

  `id` VARCHAR(32) NOT NULL  comment 'id',
  `pipeline_id` VARCHAR(32) NOT NULL  comment '产线ID',
  `version` VARCHAR(20) NOT NULL  comment '版本号',
  `publish_status` VARCHAR(20) NOT NULL  DEFAULT 'pending' comment '发布状态',
  `published_by` VARCHAR(32)   comment '发布人',
  `published_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP   comment '发布时间',
  `changelog` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '变更说明',
  `config_snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '配置快照JSON',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP   comment '创建时间'


,primary key(id)


)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci
engine=innodb 
comment '产线发布记录表'
;

CREATE  INDEX pipeline_versions_idx_versions_pipeline ON pipeline_versions(pipeline_id);

-- models/pipelines.json





-- 建库时请用以下语句，支持emoji字符
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
drop table if exists pipelines;
CREATE TABLE pipelines
(

  `id` VARCHAR(32) NOT NULL  comment 'id',
  `name` VARCHAR(200) NOT NULL  comment '产线名称',
  `description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '产线描述',
  `pipeline_type` VARCHAR(50) NOT NULL  comment '产线类型',
  `version` VARCHAR(20)   DEFAULT '1.0.0' comment '当前版本',
  `status` VARCHAR(20) NOT NULL  DEFAULT 'draft' comment '状态',
  `pipeline_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '产线配置JSON',
  `model_api_url` VARCHAR(500)   comment '模型API地址',
  `model_api_key` VARCHAR(500)   comment '模型API密钥',
  `org_id` VARCHAR(32)   DEFAULT '0' comment '所属机构ID',
  `created_by` VARCHAR(32)   comment '创建人',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP   comment '创建时间',
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP   comment '更新时间'


,primary key(id)


)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci
engine=innodb 
comment '产线定义表'
;

CREATE  INDEX pipelines_idx_pipelines_name ON pipelines(name);
CREATE  INDEX pipelines_idx_pipelines_status ON pipelines(status);

-- models/pipeline_steps.json





-- 建库时请用以下语句，支持emoji字符
-- CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
drop table if exists pipeline_steps;
CREATE TABLE pipeline_steps
(

  `id` VARCHAR(32) NOT NULL  comment 'id',
  `pipeline_id` VARCHAR(32) NOT NULL  comment '所属产线',
  `step_order` int NOT NULL  comment '步骤序号',
  `step_name` VARCHAR(100) NOT NULL  comment '步骤名称',
  `step_type` VARCHAR(50) NOT NULL  comment '步骤类型',
  `model_name` VARCHAR(100)   comment '调用模型名称',
  `step_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '步骤配置JSON',
  `input_schema` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '输入定义JSON',
  `output_schema` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   comment '输出定义JSON',
  `timeout_seconds` int   DEFAULT '300' comment '超时秒数',
  `retry_count` int   DEFAULT '0' comment '重试次数',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP   comment '创建时间'


,primary key(id)


)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci
engine=innodb 
comment '产线步骤表'
;

CREATE  INDEX pipeline_steps_idx_steps_pipeline ON pipeline_steps(pipeline_id);
CREATE UNIQUE INDEX pipeline_steps_idx_steps_order ON pipeline_steps(pipeline_id,step_order);

