Skip to content

Commit 3591d40

Browse files
committed
Use uuids
Signed-off-by: Alexis Rico <[email protected]>
1 parent 5e37639 commit 3591d40

File tree

8 files changed

+134
-998
lines changed

8 files changed

+134
-998
lines changed
Lines changed: 28 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,47 @@
1-
CREATE TYPE "public"."schedule_status" AS ENUM('disabled', 'scheduled', 'running');
2-
1+
CREATE TYPE "public"."schedule_status" AS ENUM('disabled', 'scheduled', 'running');--> statement-breakpoint
2+
CREATE TABLE "assoc_cluster_connections" (
3+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4+
"cluster_id" uuid,
5+
"connection_id" uuid
6+
);
37
--> statement-breakpoint
48
CREATE TABLE "clusters" (
5-
"id" serial PRIMARY KEY NOT NULL,
6-
"cluster_identifier" text,
7-
"integration" text,
8-
"data" jsonb,
9+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
10+
"cluster_identifier" text NOT NULL,
11+
"integration" text NOT NULL,
12+
"data" jsonb NOT NULL,
913
"region" text DEFAULT 'us-east-1' NOT NULL,
10-
CONSTRAINT "instances_integration_identifier_unique" UNIQUE("cluster_identifier", "integration")
14+
CONSTRAINT "instances_integration_identifier_unique" UNIQUE("cluster_identifier","integration")
1115
);
12-
1316
--> statement-breakpoint
1417
CREATE TABLE "connections" (
15-
"id" serial PRIMARY KEY NOT NULL,
16-
"name" text,
17-
"is_default" boolean,
18-
"connstring" text,
18+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
19+
"name" text NOT NULL,
20+
"is_default" boolean DEFAULT false NOT NULL,
21+
"connstring" text NOT NULL,
1922
"params" jsonb,
2023
CONSTRAINT "connections_name_unique" UNIQUE("name"),
2124
CONSTRAINT "connections_connstring_unique" UNIQUE("connstring")
2225
);
23-
2426
--> statement-breakpoint
2527
CREATE TABLE "dbinfo" (
26-
"id" serial PRIMARY KEY NOT NULL,
27-
"connid" integer,
28+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
29+
"connection_id" uuid,
2830
"module" text,
2931
"data" jsonb,
30-
CONSTRAINT "dbinfo_module_unique" UNIQUE("connid", "module")
32+
CONSTRAINT "dbinfo_module_unique" UNIQUE("connection_id","module")
3133
);
32-
3334
--> statement-breakpoint
3435
CREATE TABLE "integrations" (
35-
"id" serial PRIMARY KEY NOT NULL,
36+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3637
"name" text,
3738
"data" jsonb,
3839
CONSTRAINT "integrations_name_unique" UNIQUE("name")
3940
);
40-
41-
--> statement-breakpoint
42-
CREATE TABLE "assoc_cluster_connections" (
43-
"id" serial PRIMARY KEY NOT NULL,
44-
"cluster_id" integer,
45-
"connection_id" integer
46-
);
47-
4841
--> statement-breakpoint
4942
CREATE TABLE "schedules" (
50-
"id" serial PRIMARY KEY NOT NULL,
51-
"connection_id" integer NOT NULL,
43+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
44+
"connection_id" uuid NOT NULL,
5245
"playbook" varchar(255) NOT NULL,
5346
"schedule_type" varchar(255) NOT NULL,
5447
"cron_expression" varchar(255),
@@ -58,37 +51,13 @@ CREATE TABLE "schedules" (
5851
"enabled" boolean NOT NULL,
5952
"last_run" timestamp,
6053
"next_run" timestamp,
61-
"status" "schedule_status" DEFAULT 'disabled',
54+
"status" "schedule_status" DEFAULT 'disabled' NOT NULL,
6255
"failures" integer DEFAULT 0,
63-
"model" text DEFAULT 'openai-gpt-4o'
56+
"model" text DEFAULT 'openai-gpt-4o' NOT NULL
6457
);
65-
66-
--> statement-breakpoint
67-
ALTER TABLE
68-
"clusters"
69-
ADD
70-
CONSTRAINT "instances_integration_fkey" FOREIGN KEY ("integration") REFERENCES "public"."integrations"("name") ON DELETE no action ON UPDATE no action;
71-
72-
--> statement-breakpoint
73-
ALTER TABLE
74-
"dbinfo"
75-
ADD
76-
CONSTRAINT "dbinfo_connid_fkey" FOREIGN KEY ("connid") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;
77-
78-
--> statement-breakpoint
79-
ALTER TABLE
80-
"assoc_cluster_connections"
81-
ADD
82-
CONSTRAINT "assoc_instance_connections_instance_id_fkey" FOREIGN KEY ("cluster_id") REFERENCES "public"."clusters"("id") ON DELETE no action ON UPDATE no action;
83-
84-
--> statement-breakpoint
85-
ALTER TABLE
86-
"assoc_cluster_connections"
87-
ADD
88-
CONSTRAINT "assoc_instance_connections_connection_id_fkey" FOREIGN KEY ("connection_id") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;
89-
9058
--> statement-breakpoint
91-
ALTER TABLE
92-
"schedules"
93-
ADD
94-
CONSTRAINT "schedules_connection_id_fkey" FOREIGN KEY ("connection_id") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;
59+
ALTER TABLE "assoc_cluster_connections" ADD CONSTRAINT "assoc_instance_connections_instance_id_fkey" FOREIGN KEY ("cluster_id") REFERENCES "public"."clusters"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
60+
ALTER TABLE "assoc_cluster_connections" ADD CONSTRAINT "assoc_instance_connections_connection_id_fkey" FOREIGN KEY ("connection_id") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
61+
ALTER TABLE "clusters" ADD CONSTRAINT "instances_integration_fkey" FOREIGN KEY ("integration") REFERENCES "public"."integrations"("name") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
62+
ALTER TABLE "dbinfo" ADD CONSTRAINT "dbinfo_connid_fkey" FOREIGN KEY ("connection_id") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
63+
ALTER TABLE "schedules" ADD CONSTRAINT "schedules_connection_id_fkey" FOREIGN KEY ("connection_id") REFERENCES "public"."connections"("id") ON DELETE no action ON UPDATE no action;

apps/dbagent/migrations/0001_update_schema.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/dbagent/migrations/0002_uuids.sql

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)