From d2c92384b1022a5a24a1802df68b37063de3b391 Mon Sep 17 00:00:00 2001 From: justine Date: Wed, 4 Feb 2026 15:05:21 -0700 Subject: [PATCH 1/5] feat: add tables for judging rooms, judges, admins the idea is to have multiple judges and admins per room. during round 1 of judging, there may be more rooms with less judges and admins per room. in round 2, we don't need as many rooms, so we can have more judges and admins per room. right now i'm only assigning teams to rooms, but not to timeslots per room. will need to consider this. --- .../0000_judging-rooms-and-assignments.sql | 168 ++++++++++++++++++ src/server/db/schema.ts | 65 +++++++ 2 files changed, 233 insertions(+) create mode 100644 drizzle/0000_judging-rooms-and-assignments.sql diff --git a/drizzle/0000_judging-rooms-and-assignments.sql b/drizzle/0000_judging-rooms-and-assignments.sql new file mode 100644 index 0000000..f54acb3 --- /dev/null +++ b/drizzle/0000_judging-rooms-and-assignments.sql @@ -0,0 +1,168 @@ +CREATE TABLE "hackathon_hackathon_settings" ( + "id" integer PRIMARY KEY DEFAULT 1 NOT NULL, + "start_date" timestamp with time zone, + "end_date" timestamp with time zone, + "is_active" boolean DEFAULT true NOT NULL, + "current_round_id" uuid, + "metadata" text +); +--> statement-breakpoint +CREATE TABLE "hackathon_judging_assignment" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "judge_id" text NOT NULL, + "team_id" text NOT NULL, + "round_id" uuid NOT NULL, + "time_slot" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_judging_room_admin" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "room_id" uuid NOT NULL, + "admin_id" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_judging_room_judge" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "room_id" uuid NOT NULL, + "judge_id" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_judging_room" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "round_id" uuid NOT NULL, + "room_link" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_judging_round" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" text NOT NULL, + "start_time" timestamp with time zone NOT NULL, + "end_time" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_score" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "assignment_id" uuid NOT NULL, + "criteria" text NOT NULL, + "score" integer NOT NULL, + "feedback" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_account" ( + "id" text PRIMARY KEY NOT NULL, + "account_id" text NOT NULL, + "provider_id" text NOT NULL, + "user_id" text NOT NULL, + "access_token" text, + "refresh_token" text, + "id_token" text, + "access_token_expires_at" timestamp, + "refresh_token_expires_at" timestamp, + "scope" text, + "password" text, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_invitation" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "email" text NOT NULL, + "role" text, + "status" text DEFAULT 'pending' NOT NULL, + "expires_at" timestamp NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "inviter_id" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_member" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "user_id" text NOT NULL, + "role" text DEFAULT 'member' NOT NULL, + "created_at" timestamp NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hackathon_organization" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "slug" text NOT NULL, + "logo" text, + "created_at" timestamp NOT NULL, + "metadata" text, + CONSTRAINT "hackathon_organization_slug_unique" UNIQUE("slug") +); +--> statement-breakpoint +CREATE TABLE "hackathon_session" ( + "id" text PRIMARY KEY NOT NULL, + "expires_at" timestamp NOT NULL, + "token" text NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp NOT NULL, + "ip_address" text, + "user_agent" text, + "user_id" text NOT NULL, + "active_organization_id" text, + "impersonated_by" text, + CONSTRAINT "hackathon_session_token_unique" UNIQUE("token") +); +--> statement-breakpoint +CREATE TABLE "hackathon_user" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "email" text NOT NULL, + "email_verified" boolean DEFAULT false NOT NULL, + "image" text, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "role" text, + "banned" boolean DEFAULT false, + "ban_reason" text, + "ban_expires" timestamp, + "dietary_restrictions" text, + "school" text, + "faculty" text, + CONSTRAINT "hackathon_user_email_unique" UNIQUE("email") +); +--> statement-breakpoint +CREATE TABLE "hackathon_verification" ( + "id" text PRIMARY KEY NOT NULL, + "identifier" text NOT NULL, + "value" text NOT NULL, + "expires_at" timestamp NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_judge_id_hackathon_user_id_fk" FOREIGN KEY ("judge_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_team_id_hackathon_organization_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_round_id_hackathon_judging_round_id_fk" FOREIGN KEY ("round_id") REFERENCES "public"."hackathon_judging_round"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_room_admin" ADD CONSTRAINT "hackathon_judging_room_admin_room_id_hackathon_judging_room_id_fk" FOREIGN KEY ("room_id") REFERENCES "public"."hackathon_judging_room"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_room_admin" ADD CONSTRAINT "hackathon_judging_room_admin_admin_id_hackathon_user_id_fk" FOREIGN KEY ("admin_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_room_judge" ADD CONSTRAINT "hackathon_judging_room_judge_room_id_hackathon_judging_room_id_fk" FOREIGN KEY ("room_id") REFERENCES "public"."hackathon_judging_room"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_room_judge" ADD CONSTRAINT "hackathon_judging_room_judge_judge_id_hackathon_user_id_fk" FOREIGN KEY ("judge_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_judging_room" ADD CONSTRAINT "hackathon_judging_room_round_id_hackathon_judging_round_id_fk" FOREIGN KEY ("round_id") REFERENCES "public"."hackathon_judging_round"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_score" ADD CONSTRAINT "hackathon_score_assignment_id_hackathon_judging_assignment_id_fk" FOREIGN KEY ("assignment_id") REFERENCES "public"."hackathon_judging_assignment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_account" ADD CONSTRAINT "hackathon_account_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_invitation" ADD CONSTRAINT "hackathon_invitation_organization_id_hackathon_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_invitation" ADD CONSTRAINT "hackathon_invitation_inviter_id_hackathon_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_member" ADD CONSTRAINT "hackathon_member_organization_id_hackathon_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_member" ADD CONSTRAINT "hackathon_member_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hackathon_session" ADD CONSTRAINT "hackathon_session_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "judging_room_admin_room_admin_uniq" ON "hackathon_judging_room_admin" USING btree ("room_id","admin_id");--> statement-breakpoint +CREATE UNIQUE INDEX "judging_room_judge_room_judge_uniq" ON "hackathon_judging_room_judge" USING btree ("room_id","judge_id");--> statement-breakpoint +CREATE INDEX "account_userId_idx" ON "hackathon_account" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "invitation_organizationId_idx" ON "hackathon_invitation" USING btree ("organization_id");--> statement-breakpoint +CREATE INDEX "invitation_email_idx" ON "hackathon_invitation" USING btree ("email");--> statement-breakpoint +CREATE INDEX "member_organizationId_idx" ON "hackathon_member" USING btree ("organization_id");--> statement-breakpoint +CREATE INDEX "member_userId_idx" ON "hackathon_member" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "session_userId_idx" ON "hackathon_session" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "verification_identifier_idx" ON "hackathon_verification" USING btree ("identifier"); \ No newline at end of file diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 0f82868..f5d15c9 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -5,6 +5,7 @@ import { pgTableCreator, text, timestamp, + uniqueIndex, uuid, } from "drizzle-orm/pg-core"; import { organization, user } from "./auth-schema"; @@ -35,6 +36,65 @@ export const judgingRounds = createTable("judging_round", { .notNull(), }); +export const judgingRooms = createTable("judging_room", { + id: uuid("id").primaryKey().defaultRandom(), + roundId: uuid("round_id") + .references(() => judgingRounds.id, { onDelete: "cascade" }) + .notNull(), + roomLink: text("room_link").notNull(), + createdAt: timestamp("created_at", { withTimezone: true }) + .defaultNow() + .notNull(), + updatedAt: timestamp("updated_at", { withTimezone: true }) + .defaultNow() + .$onUpdate(() => new Date()) + .notNull(), +}); + +export const judgingRoomJudges = createTable( + "judging_room_judge", + { + id: uuid("id").primaryKey().defaultRandom(), + roomId: uuid("room_id") + .notNull() + .references(() => judgingRooms.id, { onDelete: "cascade" }), + judgeId: text("judge_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + createdAt: timestamp("created_at", { withTimezone: true }) + .defaultNow() + .notNull(), + }, + (table) => [ + uniqueIndex("judging_room_judge_room_judge_uniq").on( + table.roomId, + table.judgeId, + ), + ], +); + +export const judgingRoomAdmins = createTable( + "judging_room_admin", + { + id: uuid("id").primaryKey().defaultRandom(), + roomId: uuid("room_id") + .notNull() + .references(() => judgingRooms.id, { onDelete: "cascade" }), + adminId: text("admin_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + createdAt: timestamp("created_at", { withTimezone: true }) + .defaultNow() + .notNull(), + }, + (table) => [ + uniqueIndex("judging_room_admin_room_admin_uniq").on( + table.roomId, + table.adminId, + ), + ], +); + export const judgingAssignments = createTable("judging_assignment", { id: uuid("id").primaryKey().defaultRandom(), judgeId: text("judge_id") @@ -70,6 +130,11 @@ export const judgingRoundRelations = relations(judgingRounds, ({ many }) => ({ assignments: many(judgingAssignments), })); +export const judgingRoomRelations = relations(judgingRooms, ({ many }) => ({ + admins: many(judgingRoomAdmins), + judges: many(judgingRoomJudges), +})); + export const judgingAssignmentRelations = relations( judgingAssignments, ({ one, many }) => ({ From ba9e7024b531b541936a78bd8586339f72225728 Mon Sep 17 00:00:00 2001 From: justine Date: Wed, 4 Feb 2026 18:59:58 -0700 Subject: [PATCH 2/5] chore: add comments test commit to see if i still get that pre-push error --- src/server/db/schema.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index f5d15c9..c321b6b 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -41,7 +41,7 @@ export const judgingRooms = createTable("judging_room", { roundId: uuid("round_id") .references(() => judgingRounds.id, { onDelete: "cascade" }) .notNull(), - roomLink: text("room_link").notNull(), + roomLink: text("room_link").notNull(), // link to the video meeting createdAt: timestamp("created_at", { withTimezone: true }) .defaultNow() .notNull(), @@ -130,6 +130,7 @@ export const judgingRoundRelations = relations(judgingRounds, ({ many }) => ({ assignments: many(judgingAssignments), })); +// each judging room can have many admins and many judges export const judgingRoomRelations = relations(judgingRooms, ({ many }) => ({ admins: many(judgingRoomAdmins), judges: many(judgingRoomJudges), From 5a2e40265081eeef624f52c8fde98ccb966d7c7f Mon Sep 17 00:00:00 2001 From: Justine Date: Tue, 10 Feb 2026 12:37:35 -0700 Subject: [PATCH 3/5] chore: remove migration files --- .../0000_judging-rooms-and-assignments.sql | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 drizzle/0000_judging-rooms-and-assignments.sql diff --git a/drizzle/0000_judging-rooms-and-assignments.sql b/drizzle/0000_judging-rooms-and-assignments.sql deleted file mode 100644 index f54acb3..0000000 --- a/drizzle/0000_judging-rooms-and-assignments.sql +++ /dev/null @@ -1,168 +0,0 @@ -CREATE TABLE "hackathon_hackathon_settings" ( - "id" integer PRIMARY KEY DEFAULT 1 NOT NULL, - "start_date" timestamp with time zone, - "end_date" timestamp with time zone, - "is_active" boolean DEFAULT true NOT NULL, - "current_round_id" uuid, - "metadata" text -); ---> statement-breakpoint -CREATE TABLE "hackathon_judging_assignment" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "judge_id" text NOT NULL, - "team_id" text NOT NULL, - "round_id" uuid NOT NULL, - "time_slot" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_judging_room_admin" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "room_id" uuid NOT NULL, - "admin_id" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_judging_room_judge" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "room_id" uuid NOT NULL, - "judge_id" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_judging_room" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "round_id" uuid NOT NULL, - "room_link" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_judging_round" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "name" text NOT NULL, - "start_time" timestamp with time zone NOT NULL, - "end_time" timestamp with time zone NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_score" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "assignment_id" uuid NOT NULL, - "criteria" text NOT NULL, - "score" integer NOT NULL, - "feedback" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_account" ( - "id" text PRIMARY KEY NOT NULL, - "account_id" text NOT NULL, - "provider_id" text NOT NULL, - "user_id" text NOT NULL, - "access_token" text, - "refresh_token" text, - "id_token" text, - "access_token_expires_at" timestamp, - "refresh_token_expires_at" timestamp, - "scope" text, - "password" text, - "created_at" timestamp DEFAULT now() NOT NULL, - "updated_at" timestamp NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_invitation" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "email" text NOT NULL, - "role" text, - "status" text DEFAULT 'pending' NOT NULL, - "expires_at" timestamp NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "inviter_id" text NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_member" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "role" text DEFAULT 'member' NOT NULL, - "created_at" timestamp NOT NULL -); ---> statement-breakpoint -CREATE TABLE "hackathon_organization" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "slug" text NOT NULL, - "logo" text, - "created_at" timestamp NOT NULL, - "metadata" text, - CONSTRAINT "hackathon_organization_slug_unique" UNIQUE("slug") -); ---> statement-breakpoint -CREATE TABLE "hackathon_session" ( - "id" text PRIMARY KEY NOT NULL, - "expires_at" timestamp NOT NULL, - "token" text NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "updated_at" timestamp NOT NULL, - "ip_address" text, - "user_agent" text, - "user_id" text NOT NULL, - "active_organization_id" text, - "impersonated_by" text, - CONSTRAINT "hackathon_session_token_unique" UNIQUE("token") -); ---> statement-breakpoint -CREATE TABLE "hackathon_user" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "email" text NOT NULL, - "email_verified" boolean DEFAULT false NOT NULL, - "image" text, - "created_at" timestamp DEFAULT now() NOT NULL, - "updated_at" timestamp DEFAULT now() NOT NULL, - "role" text, - "banned" boolean DEFAULT false, - "ban_reason" text, - "ban_expires" timestamp, - "dietary_restrictions" text, - "school" text, - "faculty" text, - CONSTRAINT "hackathon_user_email_unique" UNIQUE("email") -); ---> statement-breakpoint -CREATE TABLE "hackathon_verification" ( - "id" text PRIMARY KEY NOT NULL, - "identifier" text NOT NULL, - "value" text NOT NULL, - "expires_at" timestamp NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "updated_at" timestamp DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_judge_id_hackathon_user_id_fk" FOREIGN KEY ("judge_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_team_id_hackathon_organization_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_assignment" ADD CONSTRAINT "hackathon_judging_assignment_round_id_hackathon_judging_round_id_fk" FOREIGN KEY ("round_id") REFERENCES "public"."hackathon_judging_round"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_room_admin" ADD CONSTRAINT "hackathon_judging_room_admin_room_id_hackathon_judging_room_id_fk" FOREIGN KEY ("room_id") REFERENCES "public"."hackathon_judging_room"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_room_admin" ADD CONSTRAINT "hackathon_judging_room_admin_admin_id_hackathon_user_id_fk" FOREIGN KEY ("admin_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_room_judge" ADD CONSTRAINT "hackathon_judging_room_judge_room_id_hackathon_judging_room_id_fk" FOREIGN KEY ("room_id") REFERENCES "public"."hackathon_judging_room"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_room_judge" ADD CONSTRAINT "hackathon_judging_room_judge_judge_id_hackathon_user_id_fk" FOREIGN KEY ("judge_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_judging_room" ADD CONSTRAINT "hackathon_judging_room_round_id_hackathon_judging_round_id_fk" FOREIGN KEY ("round_id") REFERENCES "public"."hackathon_judging_round"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_score" ADD CONSTRAINT "hackathon_score_assignment_id_hackathon_judging_assignment_id_fk" FOREIGN KEY ("assignment_id") REFERENCES "public"."hackathon_judging_assignment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_account" ADD CONSTRAINT "hackathon_account_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_invitation" ADD CONSTRAINT "hackathon_invitation_organization_id_hackathon_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_invitation" ADD CONSTRAINT "hackathon_invitation_inviter_id_hackathon_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_member" ADD CONSTRAINT "hackathon_member_organization_id_hackathon_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."hackathon_organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_member" ADD CONSTRAINT "hackathon_member_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "hackathon_session" ADD CONSTRAINT "hackathon_session_user_id_hackathon_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hackathon_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "judging_room_admin_room_admin_uniq" ON "hackathon_judging_room_admin" USING btree ("room_id","admin_id");--> statement-breakpoint -CREATE UNIQUE INDEX "judging_room_judge_room_judge_uniq" ON "hackathon_judging_room_judge" USING btree ("room_id","judge_id");--> statement-breakpoint -CREATE INDEX "account_userId_idx" ON "hackathon_account" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "invitation_organizationId_idx" ON "hackathon_invitation" USING btree ("organization_id");--> statement-breakpoint -CREATE INDEX "invitation_email_idx" ON "hackathon_invitation" USING btree ("email");--> statement-breakpoint -CREATE INDEX "member_organizationId_idx" ON "hackathon_member" USING btree ("organization_id");--> statement-breakpoint -CREATE INDEX "member_userId_idx" ON "hackathon_member" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "session_userId_idx" ON "hackathon_session" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "verification_identifier_idx" ON "hackathon_verification" USING btree ("identifier"); \ No newline at end of file From b8d149f44d34a416fc20baa2f2a39e57388151bd Mon Sep 17 00:00:00 2001 From: Justine Date: Tue, 10 Feb 2026 12:55:02 -0700 Subject: [PATCH 4/5] fix: assign teams to rooms instead of rounds --- src/server/db/schema.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index c321b6b..723937a 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -97,15 +97,12 @@ export const judgingRoomAdmins = createTable( export const judgingAssignments = createTable("judging_assignment", { id: uuid("id").primaryKey().defaultRandom(), - judgeId: text("judge_id") - .notNull() - .references(() => user.id, { onDelete: "cascade" }), teamId: text("team_id") .notNull() .references(() => organization.id, { onDelete: "cascade" }), - roundId: uuid("round_id") + roomId: uuid("room_id") .notNull() - .references(() => judgingRounds.id, { onDelete: "cascade" }), + .references(() => judgingRooms.id, { onDelete: "cascade" }), timeSlot: timestamp("time_slot", { withTimezone: true }), createdAt: timestamp("created_at", { withTimezone: true }) .defaultNow() @@ -139,17 +136,13 @@ export const judgingRoomRelations = relations(judgingRooms, ({ many }) => ({ export const judgingAssignmentRelations = relations( judgingAssignments, ({ one, many }) => ({ - judge: one(user, { - fields: [judgingAssignments.judgeId], - references: [user.id], - }), team: one(organization, { fields: [judgingAssignments.teamId], references: [organization.id], }), - round: one(judgingRounds, { - fields: [judgingAssignments.roundId], - references: [judgingRounds.id], + room: one(judgingRooms, { + fields: [judgingAssignments.roomId], + references: [judgingRooms.id], }), scores: many(scores), }), From 984388f30c715e43f9820db9a66c2bf26c6bff40 Mon Sep 17 00:00:00 2001 From: justine Date: Tue, 10 Feb 2026 18:35:09 -0700 Subject: [PATCH 5/5] fix: ci error bc of biome --- drizzle.config.ts | 18 +-- src/server/db/auth-schema.ts | 297 +++++++++++++++++------------------ 2 files changed, 157 insertions(+), 158 deletions(-) diff --git a/drizzle.config.ts b/drizzle.config.ts index f8a330a..858862b 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -3,13 +3,13 @@ import type { Config } from "drizzle-kit"; import { env } from "@/env"; export default { - schema: [ - "./src/server/db/schema.ts", // data schema - "./src/server/db/auth-schema.ts", // auth schema - ], - dialect: "postgresql", - dbCredentials: { - url: env.DATABASE_URL, - }, - tablesFilter: ["hackathon_*"], + schema: [ + "./src/server/db/schema.ts", // data schema + "./src/server/db/auth-schema.ts", // auth schema + ], + dialect: "postgresql", + dbCredentials: { + url: env.DATABASE_URL, + }, + tablesFilter: ["hackathon_*"], } satisfies Config; diff --git a/src/server/db/auth-schema.ts b/src/server/db/auth-schema.ts index d9bc44a..1e0c14f 100644 --- a/src/server/db/auth-schema.ts +++ b/src/server/db/auth-schema.ts @@ -1,196 +1,195 @@ import { - type InferInsertModel, - type InferSelectModel, - relations, + type InferInsertModel, + type InferSelectModel, + relations, } from "drizzle-orm"; import { - boolean, - index, - pgTable, - pgTableCreator, - text, - timestamp, + boolean, + index, + pgTableCreator, + text, + timestamp, } from "drizzle-orm/pg-core"; export const createTable = pgTableCreator((name) => `hackathon_${name}`); export const user = createTable("user", { - id: text("id").primaryKey(), - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified").default(false).notNull(), - image: text("image"), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") - .defaultNow() - .$onUpdate(() => /* @__PURE__ */ new Date()) - .notNull(), - role: text("role"), - banned: boolean("banned").default(false), - banReason: text("ban_reason"), - banExpires: timestamp("ban_expires"), - dietaryRestrictions: text("dietary_restrictions"), - school: text("school"), - faculty: text("faculty"), + id: text("id").primaryKey(), + name: text("name").notNull(), + email: text("email").notNull().unique(), + emailVerified: boolean("email_verified").default(false).notNull(), + image: text("image"), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at") + .defaultNow() + .$onUpdate(() => /* @__PURE__ */ new Date()) + .notNull(), + role: text("role"), + banned: boolean("banned").default(false), + banReason: text("ban_reason"), + banExpires: timestamp("ban_expires"), + dietaryRestrictions: text("dietary_restrictions"), + school: text("school"), + faculty: text("faculty"), }); export const session = createTable( - "session", - { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") - .$onUpdate(() => /* @__PURE__ */ new Date()) - .notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") - .notNull() - .references(() => user.id, { onDelete: "cascade" }), - activeOrganizationId: text("active_organization_id"), - impersonatedBy: text("impersonated_by"), - }, - (table) => [index("session_userId_idx").on(table.userId)], + "session", + { + id: text("id").primaryKey(), + expiresAt: timestamp("expires_at").notNull(), + token: text("token").notNull().unique(), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at") + .$onUpdate(() => /* @__PURE__ */ new Date()) + .notNull(), + ipAddress: text("ip_address"), + userAgent: text("user_agent"), + userId: text("user_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + activeOrganizationId: text("active_organization_id"), + impersonatedBy: text("impersonated_by"), + }, + (table) => [index("session_userId_idx").on(table.userId)], ); export const account = createTable( - "account", - { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") - .notNull() - .references(() => user.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") - .$onUpdate(() => /* @__PURE__ */ new Date()) - .notNull(), - }, - (table) => [index("account_userId_idx").on(table.userId)], + "account", + { + id: text("id").primaryKey(), + accountId: text("account_id").notNull(), + providerId: text("provider_id").notNull(), + userId: text("user_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + accessToken: text("access_token"), + refreshToken: text("refresh_token"), + idToken: text("id_token"), + accessTokenExpiresAt: timestamp("access_token_expires_at"), + refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), + scope: text("scope"), + password: text("password"), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at") + .$onUpdate(() => /* @__PURE__ */ new Date()) + .notNull(), + }, + (table) => [index("account_userId_idx").on(table.userId)], ); export const verification = createTable( - "verification", - { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") - .defaultNow() - .$onUpdate(() => /* @__PURE__ */ new Date()) - .notNull(), - }, - (table) => [index("verification_identifier_idx").on(table.identifier)], + "verification", + { + id: text("id").primaryKey(), + identifier: text("identifier").notNull(), + value: text("value").notNull(), + expiresAt: timestamp("expires_at").notNull(), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at") + .defaultNow() + .$onUpdate(() => /* @__PURE__ */ new Date()) + .notNull(), + }, + (table) => [index("verification_identifier_idx").on(table.identifier)], ); export const organization = createTable("organization", { - id: text("id").primaryKey(), - name: text("name").notNull(), - slug: text("slug").notNull().unique(), - logo: text("logo"), - createdAt: timestamp("created_at").notNull(), - metadata: text("metadata"), + id: text("id").primaryKey(), + name: text("name").notNull(), + slug: text("slug").notNull().unique(), + logo: text("logo"), + createdAt: timestamp("created_at").notNull(), + metadata: text("metadata"), }); export const member = createTable( - "member", - { - id: text("id").primaryKey(), - organizationId: text("organization_id") - .notNull() - .references(() => organization.id, { onDelete: "cascade" }), - userId: text("user_id") - .notNull() - .references(() => user.id, { onDelete: "cascade" }), - role: text("role").default("member").notNull(), - createdAt: timestamp("created_at").notNull(), - }, - (table) => [ - index("member_organizationId_idx").on(table.organizationId), - index("member_userId_idx").on(table.userId), - ], + "member", + { + id: text("id").primaryKey(), + organizationId: text("organization_id") + .notNull() + .references(() => organization.id, { onDelete: "cascade" }), + userId: text("user_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + role: text("role").default("member").notNull(), + createdAt: timestamp("created_at").notNull(), + }, + (table) => [ + index("member_organizationId_idx").on(table.organizationId), + index("member_userId_idx").on(table.userId), + ], ); export const invitation = createTable( - "invitation", - { - id: text("id").primaryKey(), - organizationId: text("organization_id") - .notNull() - .references(() => organization.id, { onDelete: "cascade" }), - email: text("email").notNull(), - role: text("role"), - status: text("status").default("pending").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").defaultNow().notNull(), - inviterId: text("inviter_id") - .notNull() - .references(() => user.id, { onDelete: "cascade" }), - }, - (table) => [ - index("invitation_organizationId_idx").on(table.organizationId), - index("invitation_email_idx").on(table.email), - ], + "invitation", + { + id: text("id").primaryKey(), + organizationId: text("organization_id") + .notNull() + .references(() => organization.id, { onDelete: "cascade" }), + email: text("email").notNull(), + role: text("role"), + status: text("status").default("pending").notNull(), + expiresAt: timestamp("expires_at").notNull(), + createdAt: timestamp("created_at").defaultNow().notNull(), + inviterId: text("inviter_id") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + }, + (table) => [ + index("invitation_organizationId_idx").on(table.organizationId), + index("invitation_email_idx").on(table.email), + ], ); export const userRelations = relations(user, ({ many }) => ({ - sessions: many(session), - accounts: many(account), - members: many(member), - invitations: many(invitation), + sessions: many(session), + accounts: many(account), + members: many(member), + invitations: many(invitation), })); export const sessionRelations = relations(session, ({ one }) => ({ - user: one(user, { - fields: [session.userId], - references: [user.id], - }), + user: one(user, { + fields: [session.userId], + references: [user.id], + }), })); export const accountRelations = relations(account, ({ one }) => ({ - user: one(user, { - fields: [account.userId], - references: [user.id], - }), + user: one(user, { + fields: [account.userId], + references: [user.id], + }), })); export const organizationRelations = relations(organization, ({ many }) => ({ - members: many(member), - invitations: many(invitation), + members: many(member), + invitations: many(invitation), })); export const memberRelations = relations(member, ({ one }) => ({ - organization: one(organization, { - fields: [member.organizationId], - references: [organization.id], - }), - user: one(user, { - fields: [member.userId], - references: [user.id], - }), + organization: one(organization, { + fields: [member.organizationId], + references: [organization.id], + }), + user: one(user, { + fields: [member.userId], + references: [user.id], + }), })); export const invitationRelations = relations(invitation, ({ one }) => ({ - organization: one(organization, { - fields: [invitation.organizationId], - references: [organization.id], - }), - user: one(user, { - fields: [invitation.inviterId], - references: [user.id], - }), + organization: one(organization, { + fields: [invitation.organizationId], + references: [organization.id], + }), + user: one(user, { + fields: [invitation.inviterId], + references: [user.id], + }), })); export type UserSelectType = InferSelectModel;