-- 提示词维度表
CREATE TABLE `prompt_dimensions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL COMMENT '维度名称，如：摘要生成、问答生成',
  `description` text COMMENT '维度描述',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='提示词维度表';

-- 提示词版本表
CREATE TABLE `prompt_versions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `dimension_id` int NOT NULL COMMENT '关联的维度ID',
  `version_number` int NOT NULL COMMENT '版本号，递增整数',
  `content` longtext NOT NULL COMMENT '提示词内容，保留原始格式（换行、空格等）',
  `is_active` tinyint(1) DEFAULT '0' COMMENT '是否为当前激活版本',
  `remark` varchar(500) DEFAULT NULL COMMENT '版本备注',
  `created_by` varchar(255) DEFAULT NULL COMMENT '创建人',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_dimension` (`dimension_id`),
  KEY `idx_dimension_active` (`dimension_id`, `is_active`),
  CONSTRAINT `fk_prompt_versions_dimension` FOREIGN KEY (`dimension_id`) REFERENCES `prompt_dimensions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='提示词版本表';
