Skip to content

Commit b2c2ce6

Browse files
committed
chore: add initial migration and journal for production database
1 parent fcfe7b8 commit b2c2ce6

File tree

3 files changed

+424
-0
lines changed

3 files changed

+424
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
CREATE TABLE "sandbox" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"name" text NOT NULL,
4+
"type" text NOT NULL,
5+
"visibility" varchar NOT NULL,
6+
"createdAt" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
7+
"user_id" text NOT NULL,
8+
"likeCount" integer DEFAULT 0 NOT NULL,
9+
"viewCount" integer DEFAULT 0 NOT NULL,
10+
"containerId" text,
11+
"repositoryId" text,
12+
CONSTRAINT "sandbox_id_unique" UNIQUE("id")
13+
);
14+
--> statement-breakpoint
15+
CREATE TABLE "sandbox_likes" (
16+
"user_id" text NOT NULL,
17+
"sandbox_id" text NOT NULL,
18+
"createdAt" timestamp DEFAULT CURRENT_TIMESTAMP,
19+
CONSTRAINT "sandbox_likes_sandbox_id_user_id_pk" PRIMARY KEY("sandbox_id","user_id")
20+
);
21+
--> statement-breakpoint
22+
CREATE TABLE "user" (
23+
"id" text PRIMARY KEY NOT NULL,
24+
"name" text NOT NULL,
25+
"email" text NOT NULL,
26+
"username" text NOT NULL,
27+
"avatarUrl" text,
28+
"githubToken" varchar,
29+
"createdAt" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
30+
"generations" integer DEFAULT 0 NOT NULL,
31+
"bio" varchar,
32+
"personalWebsite" varchar,
33+
"links" json DEFAULT '[]'::json NOT NULL,
34+
"tier" varchar DEFAULT 'FREE' NOT NULL,
35+
"tierExpiresAt" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
36+
"lastResetDate" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
37+
CONSTRAINT "user_id_unique" UNIQUE("id"),
38+
CONSTRAINT "user_username_unique" UNIQUE("username")
39+
);
40+
--> statement-breakpoint
41+
CREATE TABLE "users_to_sandboxes" (
42+
"userId" text NOT NULL,
43+
"sandboxId" text NOT NULL,
44+
"sharedOn" timestamp NOT NULL
45+
);
46+
--> statement-breakpoint
47+
ALTER TABLE "sandbox" ADD CONSTRAINT "sandbox_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
48+
ALTER TABLE "sandbox_likes" ADD CONSTRAINT "sandbox_likes_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
49+
ALTER TABLE "sandbox_likes" ADD CONSTRAINT "sandbox_likes_sandbox_id_sandbox_id_fk" FOREIGN KEY ("sandbox_id") REFERENCES "public"."sandbox"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
50+
ALTER TABLE "users_to_sandboxes" ADD CONSTRAINT "users_to_sandboxes_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
51+
ALTER TABLE "users_to_sandboxes" ADD CONSTRAINT "users_to_sandboxes_sandboxId_sandbox_id_fk" FOREIGN KEY ("sandboxId") REFERENCES "public"."sandbox"("id") ON DELETE no action ON UPDATE no action;

0 commit comments

Comments
 (0)