0011_schedules.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. CREATE TABLE `schedule_runs` (
  2. `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
  3. `schedule_id` text NOT NULL,
  4. `ts` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL,
  5. `outcome` text NOT NULL,
  6. `run_id` text,
  7. `cost_usd` real,
  8. `note` text
  9. );
  10. --> statement-breakpoint
  11. CREATE INDEX `schedule_runs_idx` ON `schedule_runs` (`schedule_id`,`id`);--> statement-breakpoint
  12. CREATE TABLE `schedules` (
  13. `id` text PRIMARY KEY NOT NULL,
  14. `session_id` text,
  15. `team_id` text,
  16. `created_by_bot_id` text,
  17. `title` text NOT NULL,
  18. `prompt` text NOT NULL,
  19. `spec` text NOT NULL,
  20. `timezone` text NOT NULL,
  21. `status` text DEFAULT 'active' NOT NULL,
  22. `status_note` text,
  23. `next_run_at` text,
  24. `last_run_at` text,
  25. `last_outcome` text,
  26. `run_count` integer DEFAULT 0 NOT NULL,
  27. `created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL,
  28. `updated_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')) NOT NULL
  29. );
  30. --> statement-breakpoint
  31. CREATE INDEX `schedules_due_idx` ON `schedules` (`status`,`next_run_at`);--> statement-breakpoint
  32. CREATE INDEX `schedules_session_idx` ON `schedules` (`session_id`);--> statement-breakpoint
  33. CREATE INDEX `schedules_team_idx` ON `schedules` (`team_id`);