Skip to content

Commit 0ab4ad6

Browse files
committed
add hack db schemas
1 parent 1fbe1c8 commit 0ab4ad6

4 files changed

Lines changed: 1031 additions & 1 deletion

File tree

website/app/modules/db/schema.server.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,40 @@ export type InsertEventTalk = typeof eventTalksTable.$inferInsert;
169169
export type SelectEventTalk = typeof eventTalksTable.$inferSelect;
170170
export type InsertEventImage = typeof eventImagesTable.$inferInsert;
171171
export type SelectEventImage = typeof eventImagesTable.$inferSelect;
172+
173+
export const hacksTable = pgTable("hacks", {
174+
id: uuid("id").primaryKey().defaultRandom(),
175+
eventId: uuid("event_id")
176+
.notNull()
177+
.references(() => eventsTable.id, { onDelete: "cascade" }),
178+
name: text("name").notNull(),
179+
project: text("description"),
180+
createdAt,
181+
updatedAt,
182+
});
183+
184+
export const hackUsersTable = pgTable("hack_users", {
185+
hackId: uuid("hack_id")
186+
.notNull()
187+
.references(() => hacksTable.id, { onDelete: "cascade" }),
188+
clerkUserId: text("clerk_user_id").notNull(),
189+
createdAt,
190+
updatedAt,
191+
});
192+
193+
export const hackVotesTable = pgTable("hack_votes", {
194+
id: uuid("id").primaryKey().defaultRandom(),
195+
hackId: uuid("hack_id")
196+
.notNull()
197+
.references(() => hacksTable.id, { onDelete: "cascade" }),
198+
clerkUserId: text("clerk_user_id").notNull(),
199+
createdAt,
200+
updatedAt,
201+
});
202+
203+
export type InsertHack = typeof hacksTable.$inferInsert;
204+
export type SelectHack = typeof hacksTable.$inferSelect;
205+
export type InsertHackUser = typeof hackUsersTable.$inferInsert;
206+
export type SelectHackUser = typeof hackUsersTable.$inferSelect;
207+
export type InsertHackVote = typeof hackVotesTable.$inferInsert;
208+
export type SelectHackVote = typeof hackVotesTable.$inferSelect;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE TABLE "hack_users" (
2+
"hack_id" uuid NOT NULL,
3+
"clerk_user_id" text NOT NULL,
4+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
5+
"updated_at" timestamp with time zone NOT NULL
6+
);
7+
--> statement-breakpoint
8+
CREATE TABLE "hack_votes" (
9+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
10+
"hack_id" uuid NOT NULL,
11+
"clerk_user_id" text NOT NULL,
12+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
13+
"updated_at" timestamp with time zone NOT NULL
14+
);
15+
--> statement-breakpoint
16+
CREATE TABLE "hacks" (
17+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
18+
"event_id" uuid NOT NULL,
19+
"name" text NOT NULL,
20+
"description" text,
21+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
22+
"updated_at" timestamp with time zone NOT NULL
23+
);
24+
--> statement-breakpoint
25+
ALTER TABLE "hack_users" ADD CONSTRAINT "hack_users_hack_id_hacks_id_fk" FOREIGN KEY ("hack_id") REFERENCES "public"."hacks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
26+
ALTER TABLE "hack_votes" ADD CONSTRAINT "hack_votes_hack_id_hacks_id_fk" FOREIGN KEY ("hack_id") REFERENCES "public"."hacks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
27+
ALTER TABLE "hacks" ADD CONSTRAINT "hacks_event_id_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."events"("id") ON DELETE cascade ON UPDATE no action;

0 commit comments

Comments
 (0)