Skip to content

Commit ccd1695

Browse files
waleedlatif1claude
andcommitted
chore(data-drains): regenerate migration on top of staging + bump route baseline
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 22502ce commit ccd1695

4 files changed

Lines changed: 15838 additions & 2 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
CREATE TYPE "public"."data_drain_cadence" AS ENUM('hourly', 'daily');--> statement-breakpoint
2+
CREATE TYPE "public"."data_drain_destination" AS ENUM('s3', 'webhook');--> statement-breakpoint
3+
CREATE TYPE "public"."data_drain_run_status" AS ENUM('running', 'success', 'failed');--> statement-breakpoint
4+
CREATE TYPE "public"."data_drain_run_trigger" AS ENUM('cron', 'manual');--> statement-breakpoint
5+
CREATE TYPE "public"."data_drain_source" AS ENUM('workflow_logs', 'job_logs', 'audit_logs', 'copilot_chats', 'copilot_runs');--> statement-breakpoint
6+
CREATE TABLE "data_drain_runs" (
7+
"id" text PRIMARY KEY NOT NULL,
8+
"drain_id" text NOT NULL,
9+
"status" "data_drain_run_status" NOT NULL,
10+
"trigger" "data_drain_run_trigger" NOT NULL,
11+
"started_at" timestamp DEFAULT now() NOT NULL,
12+
"finished_at" timestamp,
13+
"rows_exported" integer DEFAULT 0 NOT NULL,
14+
"bytes_written" bigint DEFAULT 0 NOT NULL,
15+
"cursor_before" text,
16+
"cursor_after" text,
17+
"error" text,
18+
"locators" jsonb DEFAULT '[]'::jsonb NOT NULL
19+
);
20+
--> statement-breakpoint
21+
CREATE TABLE "data_drains" (
22+
"id" text PRIMARY KEY NOT NULL,
23+
"organization_id" text NOT NULL,
24+
"name" text NOT NULL,
25+
"source" "data_drain_source" NOT NULL,
26+
"destination_type" "data_drain_destination" NOT NULL,
27+
"destination_config" jsonb NOT NULL,
28+
"destination_credentials" text NOT NULL,
29+
"schedule_cadence" "data_drain_cadence" NOT NULL,
30+
"enabled" boolean DEFAULT true NOT NULL,
31+
"cursor" text,
32+
"last_run_at" timestamp,
33+
"last_success_at" timestamp,
34+
"created_by" text NOT NULL,
35+
"created_at" timestamp DEFAULT now() NOT NULL,
36+
"updated_at" timestamp DEFAULT now() NOT NULL
37+
);
38+
--> statement-breakpoint
39+
ALTER TABLE "data_drain_runs" ADD CONSTRAINT "data_drain_runs_drain_id_data_drains_id_fk" FOREIGN KEY ("drain_id") REFERENCES "public"."data_drains"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
40+
ALTER TABLE "data_drains" ADD CONSTRAINT "data_drains_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
41+
ALTER TABLE "data_drains" ADD CONSTRAINT "data_drains_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
42+
CREATE INDEX "data_drain_runs_drain_started_idx" ON "data_drain_runs" USING btree ("drain_id","started_at");--> statement-breakpoint
43+
CREATE INDEX "data_drains_org_idx" ON "data_drains" USING btree ("organization_id");--> statement-breakpoint
44+
CREATE INDEX "data_drains_due_idx" ON "data_drains" USING btree ("enabled","last_run_at");--> statement-breakpoint
45+
CREATE UNIQUE INDEX "data_drains_org_name_unique" ON "data_drains" USING btree ("organization_id","name");--> statement-breakpoint
46+
CREATE INDEX "audit_log_workspace_created_at_id_idx" ON "audit_log" USING btree ("workspace_id",date_trunc('milliseconds', "created_at"),"id");--> statement-breakpoint
47+
CREATE INDEX "copilot_chats_workspace_created_at_id_idx" ON "copilot_chats" USING btree ("workspace_id",date_trunc('milliseconds', "created_at"),"id");--> statement-breakpoint
48+
CREATE INDEX "copilot_runs_workspace_completed_at_id_idx" ON "copilot_runs" USING btree ("workspace_id",date_trunc('milliseconds', "completed_at"),"id");--> statement-breakpoint
49+
CREATE INDEX "job_execution_logs_workspace_ended_at_id_idx" ON "job_execution_logs" USING btree ("workspace_id",date_trunc('milliseconds', "ended_at"),"id");--> statement-breakpoint
50+
CREATE INDEX "workflow_execution_logs_workspace_ended_at_id_idx" ON "workflow_execution_logs" USING btree ("workspace_id",date_trunc('milliseconds', "ended_at"),"id");

0 commit comments

Comments
 (0)