Skip to content

Commit b476b8d

Browse files
committed
reran migrations
1 parent c18fbcf commit b476b8d

File tree

4 files changed

+11480
-89
lines changed

4 files changed

+11480
-89
lines changed

packages/db/migrations/0154_dark_speedball.sql

Lines changed: 0 additions & 89 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CREATE TABLE "user_table_definitions" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"workspace_id" text NOT NULL,
4+
"name" text NOT NULL,
5+
"description" text,
6+
"schema" jsonb NOT NULL,
7+
"max_rows" integer DEFAULT 10000 NOT NULL,
8+
"row_count" integer DEFAULT 0 NOT NULL,
9+
"created_by" text NOT NULL,
10+
"created_at" timestamp DEFAULT now() NOT NULL,
11+
"updated_at" timestamp DEFAULT now() NOT NULL
12+
);
13+
--> statement-breakpoint
14+
CREATE TABLE "user_table_rows" (
15+
"id" text PRIMARY KEY NOT NULL,
16+
"table_id" text NOT NULL,
17+
"workspace_id" text NOT NULL,
18+
"data" jsonb NOT NULL,
19+
"created_at" timestamp DEFAULT now() NOT NULL,
20+
"updated_at" timestamp DEFAULT now() NOT NULL,
21+
"created_by" text
22+
);
23+
--> statement-breakpoint
24+
ALTER TABLE "user_table_definitions" ADD CONSTRAINT "user_table_definitions_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
25+
ALTER TABLE "user_table_definitions" ADD CONSTRAINT "user_table_definitions_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
26+
ALTER TABLE "user_table_rows" ADD CONSTRAINT "user_table_rows_table_id_user_table_definitions_id_fk" FOREIGN KEY ("table_id") REFERENCES "public"."user_table_definitions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
27+
ALTER TABLE "user_table_rows" ADD CONSTRAINT "user_table_rows_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
28+
ALTER TABLE "user_table_rows" ADD CONSTRAINT "user_table_rows_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
29+
CREATE INDEX "user_table_def_workspace_id_idx" ON "user_table_definitions" USING btree ("workspace_id");--> statement-breakpoint
30+
CREATE UNIQUE INDEX "user_table_def_workspace_name_unique" ON "user_table_definitions" USING btree ("workspace_id","name");--> statement-breakpoint
31+
CREATE INDEX "user_table_rows_table_id_idx" ON "user_table_rows" USING btree ("table_id");--> statement-breakpoint
32+
CREATE INDEX "user_table_rows_workspace_id_idx" ON "user_table_rows" USING btree ("workspace_id");--> statement-breakpoint
33+
CREATE INDEX "user_table_rows_data_gin_idx" ON "user_table_rows" USING gin ("data");--> statement-breakpoint
34+
CREATE INDEX "user_table_rows_workspace_table_idx" ON "user_table_rows" USING btree ("workspace_id","table_id");

0 commit comments

Comments
 (0)