File
Blob: drizzle/project-do/0000_bright_stephen_strange.sql
| 1 | CREATE TABLE `project_config` ( |
| 2 | `project_id` text PRIMARY KEY NOT NULL, |
| 3 | `name` text NOT NULL, |
| 4 | `repo_url` text NOT NULL, |
| 5 | `default_branch` text NOT NULL, |
| 6 | `config_path` text NOT NULL, |
| 7 | `repo_token_ciphertext` blob, |
| 8 | `repo_token_key_version` integer, |
| 9 | `repo_token_nonce` blob, |
| 10 | `dispatch_mode` text NOT NULL, |
| 11 | `execution_runtime` text NOT NULL, |
| 12 | `created_at` integer NOT NULL, |
| 13 | `updated_at` integer NOT NULL |
| 14 | ); |
| 15 | --> statement-breakpoint |
| 16 | CREATE TABLE `project_runs` ( |
| 17 | `id` text PRIMARY KEY NOT NULL, |
| 18 | `project_id` text NOT NULL, |
| 19 | `run_id` text NOT NULL, |
| 20 | `trigger_type` text NOT NULL, |
| 21 | `triggered_by_user_id` text, |
| 22 | `branch` text NOT NULL, |
| 23 | `commit_sha` text, |
| 24 | `provider` text, |
| 25 | `delivery_id` text, |
| 26 | `repo_url` text NOT NULL, |
| 27 | `config_path` text NOT NULL, |
| 28 | `position` integer, |
| 29 | `status` text NOT NULL, |
| 30 | `d1_sync_status` text NOT NULL, |
| 31 | `dispatch_mode` text NOT NULL, |
| 32 | `execution_runtime` text NOT NULL, |
| 33 | `dispatch_status` text NOT NULL, |
| 34 | `dispatch_attempts` integer NOT NULL, |
| 35 | `last_error` text, |
| 36 | `created_at` integer NOT NULL, |
| 37 | `cancel_requested_at` integer |
| 38 | ); |
| 39 | --> statement-breakpoint |
| 40 | CREATE UNIQUE INDEX `idx_project_runs_project_position` ON `project_runs` (`project_id`,`position`);--> statement-breakpoint |
| 41 | CREATE INDEX `idx_project_runs_project_status_position` ON `project_runs` (`project_id`,`status`,`position`);--> statement-breakpoint |
| 42 | CREATE UNIQUE INDEX `idx_project_runs_run_id` ON `project_runs` (`run_id`);--> statement-breakpoint |
| 43 | CREATE TABLE `project_state` ( |
| 44 | `project_id` text PRIMARY KEY NOT NULL, |
| 45 | `active_run_id` text, |
| 46 | `project_index_sync_status` text NOT NULL, |
| 47 | `updated_at` integer NOT NULL |
| 48 | ); |
| 49 | --> statement-breakpoint |
| 50 | CREATE TABLE `project_webhook_deliveries` ( |
| 51 | `id` text PRIMARY KEY NOT NULL, |
| 52 | `project_id` text NOT NULL, |
| 53 | `provider` text NOT NULL, |
| 54 | `delivery_id` text NOT NULL, |
| 55 | `event_kind` text NOT NULL, |
| 56 | `event_name` text NOT NULL, |
| 57 | `outcome` text NOT NULL, |
| 58 | `repo_url` text NOT NULL, |
| 59 | `ref` text, |
| 60 | `branch` text, |
| 61 | `commit_sha` text, |
| 62 | `before_sha` text, |
| 63 | `run_id` text, |
| 64 | `received_at` integer NOT NULL |
| 65 | ); |
| 66 | --> statement-breakpoint |
| 67 | CREATE UNIQUE INDEX `idx_project_webhook_deliveries_project_provider_delivery` ON `project_webhook_deliveries` (`project_id`,`provider`,`delivery_id`);--> statement-breakpoint |
| 68 | CREATE INDEX `idx_project_webhook_deliveries_project_received_at` ON `project_webhook_deliveries` (`project_id`,`received_at`);--> statement-breakpoint |
| 69 | CREATE TABLE `project_webhooks` ( |
| 70 | `id` text PRIMARY KEY NOT NULL, |
| 71 | `project_id` text NOT NULL, |
| 72 | `provider` text NOT NULL, |
| 73 | `config_json` text, |
| 74 | `secret_ciphertext` blob NOT NULL, |
| 75 | `secret_key_version` integer NOT NULL, |
| 76 | `secret_nonce` blob NOT NULL, |
| 77 | `enabled` integer NOT NULL, |
| 78 | `created_at` integer NOT NULL, |
| 79 | `updated_at` integer NOT NULL |
| 80 | ); |
| 81 | --> statement-breakpoint |
| 82 | CREATE UNIQUE INDEX `idx_project_webhooks_project_provider` ON `project_webhooks` (`project_id`,`provider`);--> statement-breakpoint |
| 83 | CREATE INDEX `idx_project_webhooks_provider_enabled` ON `project_webhooks` (`provider`,`enabled`);--> statement-breakpoint |
| 84 | CREATE INDEX `idx_project_webhooks_project_enabled` ON `project_webhooks` (`project_id`,`enabled`); |