-- AI Analyzed Commits 表（增量标记，防止重复分析）
CREATE TABLE IF NOT EXISTS `ai_analyzed_commits` (
  `id` varchar(50) NOT NULL PRIMARY KEY,
  `commit_sha` varchar(200) NOT NULL,
  `batch_id` varchar(50) NOT NULL,
  `created_at` datetime NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `uniq_analyzed_sha` ON `ai_analyzed_commits` (`commit_sha`);
--> statement-breakpoint
-- objectives 表加 source 字段
ALTER TABLE `objectives` ADD COLUMN `source` varchar(50) DEFAULT 'manual';
--> statement-breakpoint
-- key_results 表加 source 和 source_key 字段
ALTER TABLE `key_results` ADD COLUMN `source` varchar(50) DEFAULT 'manual';
--> statement-breakpoint
ALTER TABLE `key_results` ADD COLUMN `source_key` varchar(300) NULL;
--> statement-breakpoint
-- sync_logs source 枚举扩展
ALTER TABLE `sync_logs` MODIFY COLUMN `source` enum('plane','gitea','ai_okr') NOT NULL;
