forked from wundergraph/cosmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0057_late_golden_guardian.sql
66 lines (66 loc) · 3.16 KB
/
0057_late_golden_guardian.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CREATE TABLE IF NOT EXISTS "federated_graph_clients" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"federated_graph_id" uuid NOT NULL,
"name" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone,
"created_by_id" uuid NOT NULL,
"updated_by_id" uuid,
CONSTRAINT "federated_graph_client_name" UNIQUE("federated_graph_id","name")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "federated_graph_persisted_operations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"federated_graph_id" uuid NOT NULL,
"client_id" uuid NOT NULL,
"hash" text NOT NULL,
"file_path" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone,
"created_by_id" uuid NOT NULL,
"updated_by_id" uuid,
CONSTRAINT "federated_graph_operation_hash" UNIQUE("federated_graph_id","hash"),
CONSTRAINT "federated_graph_operation_file_hash" UNIQUE("federated_graph_id","file_path")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_clients" ADD CONSTRAINT "federated_graph_clients_federated_graph_id_federated_graphs_id_fk" FOREIGN KEY ("federated_graph_id") REFERENCES "federated_graphs"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_clients" ADD CONSTRAINT "federated_graph_clients_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_clients" ADD CONSTRAINT "federated_graph_clients_updated_by_id_users_id_fk" FOREIGN KEY ("updated_by_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_persisted_operations" ADD CONSTRAINT "federated_graph_persisted_operations_federated_graph_id_federated_graphs_id_fk" FOREIGN KEY ("federated_graph_id") REFERENCES "federated_graphs"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_persisted_operations" ADD CONSTRAINT "federated_graph_persisted_operations_client_id_federated_graph_clients_id_fk" FOREIGN KEY ("client_id") REFERENCES "federated_graph_clients"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_persisted_operations" ADD CONSTRAINT "federated_graph_persisted_operations_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "federated_graph_persisted_operations" ADD CONSTRAINT "federated_graph_persisted_operations_updated_by_id_users_id_fk" FOREIGN KEY ("updated_by_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;