-- 创建节点模板表
CREATE TABLE IF NOT EXISTS `node_templates` (
  `id` CHAR(36) NOT NULL PRIMARY KEY COMMENT '模板ID',
  `name` VARCHAR(100) NOT NULL COMMENT '模板名称',
  `description` TEXT COMMENT '模板描述',
  `category` VARCHAR(50) COMMENT '分类: text_generation/data_analysis/code_generation/translation/summarization/qa/other',
  `tags` JSON COMMENT '标签列表',
  `prompt` TEXT NOT NULL COMMENT '提示词模板（支持变量占位符，如 {{variable}}）',
  `variables` JSON COMMENT '变量定义列表',
  `provider` VARCHAR(50) DEFAULT 'deepseek' COMMENT '默认LLM提供商',
  `model` VARCHAR(100) DEFAULT 'deepseek-chat' COMMENT '默认模型',
  `temperature` VARCHAR(10) DEFAULT '0.7' COMMENT '默认温度参数',
  `max_tokens` INT DEFAULT 1500 COMMENT '默认最大token数',
  `is_public` BOOLEAN DEFAULT FALSE COMMENT '是否公开',
  `is_featured` BOOLEAN DEFAULT FALSE COMMENT '是否精选',
  `use_count` INT DEFAULT 0 COMMENT '使用次数',
  `user_id` CHAR(36) NOT NULL COMMENT '创建者ID',
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  INDEX `idx_user_id` (`user_id`),
  INDEX `idx_category` (`category`),
  INDEX `idx_is_public` (`is_public`),
  INDEX `idx_is_featured` (`is_featured`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='节点模板表';
