Refactor drizzle and db folder
This commit is contained in:
parent
e96dfb2d74
commit
c493ac342b
31 changed files with 22 additions and 23 deletions
|
|
@ -1,39 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS "Suggestion" (
|
||||
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
"documentId" uuid NOT NULL,
|
||||
"documentCreatedAt" timestamp NOT NULL,
|
||||
"originalText" text NOT NULL,
|
||||
"suggestedText" text NOT NULL,
|
||||
"description" text,
|
||||
"isResolved" boolean DEFAULT false NOT NULL,
|
||||
"userId" uuid NOT NULL,
|
||||
"createdAt" timestamp NOT NULL,
|
||||
CONSTRAINT "Suggestion_id_pk" PRIMARY KEY("id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "Document" (
|
||||
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
"createdAt" timestamp NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"content" text,
|
||||
"userId" uuid NOT NULL,
|
||||
CONSTRAINT "Document_id_createdAt_pk" PRIMARY KEY("id","createdAt")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "Suggestion" ADD CONSTRAINT "Suggestion_userId_User_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "Suggestion" ADD CONSTRAINT "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk" FOREIGN KEY ("documentId","documentCreatedAt") REFERENCES "public"."Document"("id","createdAt") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "Document" ADD CONSTRAINT "Document_userId_User_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
Loading…
Add table
Add a link
Reference in a new issue