lobster_replay_archive_phase2.sql 937 B

1234567891011121314151617181920
  1. -- Phase 2: replay cold archive table + hot buffer index
  2. -- Run on tenant DB when upgrading lobster learning module
  3. CREATE TABLE IF NOT EXISTS `lobster_learning_replay_archive` (
  4. `id` bigint NOT NULL AUTO_INCREMENT,
  5. `company_id` bigint NOT NULL COMMENT 'company id',
  6. `instance_id` bigint DEFAULT NULL,
  7. `node_code` varchar(100) DEFAULT NULL,
  8. `customer_message` text,
  9. `ai_reply` text,
  10. `quality_score` double DEFAULT NULL,
  11. `create_time` datetime DEFAULT NULL,
  12. `archived_time` datetime DEFAULT CURRENT_TIMESTAMP,
  13. PRIMARY KEY (`id`),
  14. KEY `idx_company_archived` (`company_id`, `archived_time`),
  15. KEY `idx_company_quality` (`company_id`, `quality_score`)
  16. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='lobster replay cold archive';
  17. ALTER TABLE `lobster_learning_replay_buffer`
  18. ADD INDEX `idx_company_quality_time` (`company_id`, `quality_score`, `create_time`);