[
  {
    "version": "1.2.5",
    "sql": "ALTER TABLE Projects ADD COLUMN test VARCHAR(255) DEFAULT '';"
  },
  {
    "version": "1.3.3",
    "sql": "CREATE TABLE IF NOT EXISTS Task (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  taskType VARCHAR(255) NOT NULL,\n  status INT NOT NULL,\n  startTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  endTime TIMESTAMP NULL,\n  completedCount INT DEFAULT 0,\n  totalCount INT DEFAULT 0,\n  modelInfo TEXT NOT NULL,\n  language VARCHAR(20) DEFAULT 'zh-CN',\n  detail TEXT DEFAULT '',\n  note TEXT DEFAULT '',\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE\n);\n\nCREATE INDEX idx_task_projectId ON Task(projectId);"
  },
  {
    "version": "1.3.6",
    "sql": "CREATE TABLE IF NOT EXISTS GaPairs (\n id VARCHAR(255) NOT NULL,\n projectId VARCHAR(255) NOT NULL,\n fileId VARCHAR(255) NOT NULL,\n pairNumber INT NOT NULL,\n genreTitle VARCHAR(255) NOT NULL,\n genreDesc TEXT NOT NULL,\n audienceTitle VARCHAR(255) NOT NULL,\n audienceDesc TEXT NOT NULL,\n isActive BOOLEAN DEFAULT 1 NOT NULL,\n createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (id),\n FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n FOREIGN KEY (fileId) REFERENCES UploadFiles(id) ON DELETE CASCADE,\n UNIQUE (fileId, pairNumber)\n);\n\nCREATE INDEX idx_gapairs_projectId ON GaPairs(projectId);\nCREATE INDEX idx_gapairs_fileId ON GaPairs(fileId);"
  },
  {
    "version": "1.3.6",
    "sql": "ALTER TABLE Questions ADD COLUMN gaPairId VARCHAR(255) NULL;"
  },
  {
    "version": "1.3.6",
    "sql": "ALTER TABLE Questions ADD FOREIGN KEY (gaPairId) REFERENCES GaPairs(id) ON DELETE SET NULL;\n\nCREATE INDEX idx_questions_gaPairId ON Questions(gaPairId);"
  },
  {
    "version": "1.4.0",
    "sql": "ALTER TABLE Datasets ADD COLUMN score REAL DEFAULT 0 NOT NULL;\nALTER TABLE Datasets ADD COLUMN tags TEXT DEFAULT '[]' NOT NULL;\nALTER TABLE Datasets ADD COLUMN note TEXT DEFAULT '' NOT NULL;\nALTER TABLE Datasets ADD COLUMN other TEXT DEFAULT '' NOT NULL;\nALTER TABLE Projects ADD COLUMN cleanPrompt TEXT DEFAULT '' NOT NULL;"
  },
  {
    "version": "1.5.0",
    "sql": "CREATE TABLE IF NOT EXISTS CustomPrompts (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  promptType VARCHAR(255) NOT NULL,\n  promptKey VARCHAR(255) NOT NULL,\n  language VARCHAR(10) NOT NULL,\n  content TEXT NOT NULL,\n  isActive BOOLEAN DEFAULT 1 NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n  UNIQUE (projectId, promptType, promptKey, language)\n);\n\nCREATE INDEX idx_customprompts_projectId ON CustomPrompts(projectId);\nCREATE INDEX idx_customprompts_project_type ON CustomPrompts(projectId, promptType);\nCREATE INDEX idx_customprompts_project_language ON CustomPrompts(projectId, language);"
  },
  {
    "version": "1.5.0",
    "sql": "ALTER TABLE Datasets ADD COLUMN aiEvaluation TEXT DEFAULT '' NOT NULL;"
  },
  {
    "version": "1.5.0",
    "sql": "CREATE TABLE IF NOT EXISTS DatasetConversations (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  questionId VARCHAR(255) NOT NULL,\n  question TEXT NOT NULL,\n  chunkId VARCHAR(255) NOT NULL,\n  model VARCHAR(255) NOT NULL,\n  questionLabel VARCHAR(255) NOT NULL,\n  score REAL DEFAULT 0 NOT NULL,\n  aiEvaluation TEXT DEFAULT '' NOT NULL,\n  tags TEXT DEFAULT '' NOT NULL,\n  note TEXT DEFAULT '' NOT NULL,\n  scenario TEXT NOT NULL,\n  roleA TEXT NOT NULL,\n  roleB TEXT NOT NULL,\n  turnCount INT NOT NULL,\n  maxTurns INT NOT NULL,\n  rawMessages TEXT NOT NULL,\n  confirmed BOOLEAN DEFAULT 0 NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE\n);\n\nCREATE INDEX idx_datasetconversations_projectId ON DatasetConversations(projectId);"
  },
  {
    "version": "1.6.0",
    "description": "为 Questions 表添加图片相关字段",
    "sql": "ALTER TABLE Questions ADD COLUMN imageId VARCHAR(255) NULL;\nALTER TABLE Questions ADD COLUMN imageName VARCHAR(255) NULL;\nALTER TABLE Questions ADD COLUMN templateId VARCHAR(255) NULL;"
  },
  {
    "version": "1.6.0",
    "description": "为 Questions 表添加图片相关索引",
    "sql": "CREATE INDEX idx_questions_imageId ON Questions(imageId);\nCREATE INDEX idx_questions_templateId ON Questions(templateId);"
  },
  {
    "version": "1.6.0",
    "description": "为 Datasets 表添加 answerType 字段",
    "sql": "ALTER TABLE Datasets ADD COLUMN answerType VARCHAR(50) DEFAULT 'text';"
  },
  {
    "version": "1.6.0",
    "description": "创建 Images 表",
    "sql": "CREATE TABLE IF NOT EXISTS Images (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  imageName VARCHAR(255) NOT NULL,\n  path TEXT NOT NULL,\n  size INT NOT NULL,\n  width INT NULL,\n  height INT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n  UNIQUE (projectId, imageName)\n);\n\nCREATE INDEX idx_images_projectId ON Images(projectId);"
  },
  {
    "version": "1.6.0",
    "description": "创建 ImageDatasets 表",
    "sql": "CREATE TABLE IF NOT EXISTS ImageDatasets (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  imageId VARCHAR(255) NOT NULL,\n  imageName VARCHAR(255) NOT NULL,\n  questionId VARCHAR(255) NULL,\n  question TEXT NOT NULL,\n  answer TEXT NOT NULL,\n  answerType VARCHAR(50) DEFAULT 'text',\n  model VARCHAR(255) NOT NULL,\n  confirmed BOOLEAN DEFAULT 0 NOT NULL,\n  score REAL DEFAULT 0 NOT NULL,\n  tags TEXT DEFAULT '' NOT NULL,\n  note TEXT DEFAULT '' NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n  FOREIGN KEY (imageId) REFERENCES Images(id) ON DELETE CASCADE\n);\n\nCREATE INDEX idx_imagedatasets_projectId ON ImageDatasets(projectId);\nCREATE INDEX idx_imagedatasets_imageId ON ImageDatasets(imageId);\nCREATE INDEX idx_imagedatasets_questionId ON ImageDatasets(questionId);"
  },
  {
    "version": "1.6.0",
    "description": "创建 QuestionTemplates 表",
    "sql": "CREATE TABLE IF NOT EXISTS QuestionTemplates (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  question TEXT NOT NULL,\n  sourceType VARCHAR(50) NOT NULL,\n  answerType VARCHAR(50) NOT NULL,\n  description TEXT DEFAULT '' NOT NULL,\n  labels TEXT DEFAULT '' NOT NULL,\n  customFormat TEXT DEFAULT '' NOT NULL,\n  \"order\" INT DEFAULT 0 NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE\n);\n\nCREATE INDEX idx_questiontemplates_projectId ON QuestionTemplates(projectId);\nCREATE INDEX idx_questiontemplates_project_source ON QuestionTemplates(projectId, sourceType);"
  },
  {
    "version": "1.6.2",
    "description": "创建 LlmUsageLogs 表 - LLM 调用统计日志",
    "sql": "CREATE TABLE IF NOT EXISTS LlmUsageLogs (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  provider VARCHAR(255) NOT NULL,\n  model VARCHAR(255) NOT NULL,\n  inputTokens INT DEFAULT 0 NOT NULL,\n  outputTokens INT DEFAULT 0 NOT NULL,\n  totalTokens INT DEFAULT 0 NOT NULL,\n  latency INT DEFAULT 0 NOT NULL,\n  status VARCHAR(50) DEFAULT 'SUCCESS' NOT NULL,\n  errorMessage TEXT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  dateString VARCHAR(10) NOT NULL,\n  PRIMARY KEY (id)\n);\n\nCREATE INDEX idx_llmusagelogs_project_date ON LlmUsageLogs(projectId, dateString);\nCREATE INDEX idx_llmusagelogs_dateString ON LlmUsageLogs(dateString);\nCREATE INDEX idx_llmusagelogs_provider ON LlmUsageLogs(provider);\nCREATE INDEX idx_llmusagelogs_model ON LlmUsageLogs(model);"
  },
  {
    "version": "1.6.2",
    "description": "为 Tags 和 Questions 表添加索引",
    "sql": "CREATE INDEX idx_tags_project_label ON Tags(projectId, label);\nCREATE INDEX idx_tags_project_parentId ON Tags(projectId, parentId);\nCREATE INDEX idx_questions_project_label ON Questions(projectId, label);"
  },
  {
    "version": "1.7.0",
    "description": "创建 EvalDatasets 表",
    "sql": "CREATE TABLE IF NOT EXISTS EvalDatasets (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  question TEXT NOT NULL,\n  questionType VARCHAR(50) NOT NULL,\n  chunkId VARCHAR(255) NULL,\n  options TEXT DEFAULT '' NOT NULL,\n  correctAnswer TEXT NOT NULL,\n  tags TEXT DEFAULT '' NOT NULL,\n  note TEXT DEFAULT '' NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n  FOREIGN KEY (chunkId) REFERENCES Chunks(id) ON DELETE SET NULL\n);\n\nCREATE INDEX idx_evaldatasets_projectId ON EvalDatasets(projectId);\nCREATE INDEX idx_evaldatasets_project_type ON EvalDatasets(projectId, questionType);\nCREATE INDEX idx_evaldatasets_chunkId ON EvalDatasets(chunkId);"
  },
  {
    "version": "1.7.0",
    "description": "创建 EvalResults 表",
    "sql": "CREATE TABLE IF NOT EXISTS EvalResults (\n  id VARCHAR(255) NOT NULL,\n  projectId VARCHAR(255) NOT NULL,\n  taskId VARCHAR(255) NOT NULL,\n  evalDatasetId VARCHAR(255) NOT NULL,\n  modelAnswer TEXT NOT NULL,\n  score REAL DEFAULT 0 NOT NULL,\n  isCorrect BOOLEAN DEFAULT 0 NOT NULL,\n  judgeResponse TEXT DEFAULT '' NOT NULL,\n  duration INT DEFAULT 0 NOT NULL,\n  status INT DEFAULT 0 NOT NULL,\n  errorMessage TEXT DEFAULT '' NOT NULL,\n  createAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  updateAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (id),\n  FOREIGN KEY (projectId) REFERENCES Projects(id) ON DELETE CASCADE,\n  FOREIGN KEY (evalDatasetId) REFERENCES EvalDatasets(id) ON DELETE CASCADE,\n  UNIQUE (taskId, evalDatasetId)\n);\n\nCREATE INDEX idx_evalresults_projectId ON EvalResults(projectId);\nCREATE INDEX idx_evalresults_taskId ON EvalResults(taskId);\nCREATE INDEX idx_evalresults_evalDatasetId ON EvalResults(evalDatasetId);"
  }
]
