From 39810d47cce69e183f6bd383fbb04c45e0246c3b Mon Sep 17 00:00:00 2001 From: aamoghS Date: Wed, 18 Feb 2026 17:01:46 -0500 Subject: [PATCH] updated the schema --- packages/db/src/schemas/auth.ts | 28 +++++------ packages/db/src/schemas/hackathons.ts | 36 +++++++------- packages/db/src/schemas/judge.ts | 48 +++++++++---------- packages/db/src/schemas/members.ts | 20 ++++---- packages/db/src/schemas/security.ts | 12 ++--- packages/db/src/schemas/stripe.ts | 8 ++-- .../components/portal/LinkStripeAccount.tsx | 35 +++++++------- 7 files changed, 93 insertions(+), 94 deletions(-) diff --git a/packages/db/src/schemas/auth.ts b/packages/db/src/schemas/auth.ts index 7036604..3ee22c6 100644 --- a/packages/db/src/schemas/auth.ts +++ b/packages/db/src/schemas/auth.ts @@ -7,10 +7,10 @@ export const users = pgTable("user", { email: text("email").notNull(), emailVerified: timestamp("emailVerified", { mode: "date" }), image: text("image"), -}, (table) => ({ - emailIdx: index("user_email_idx").on(table.email), - nameIdx: index("user_name_idx").on(table.name), -})); +}, (table) => [ + index("user_email_idx").on(table.email), + index("user_name_idx").on(table.name), +]); export const accounts = pgTable( "account", @@ -29,12 +29,12 @@ export const accounts = pgTable( id_token: text("id_token"), session_state: text("session_state"), }, - (account) => ({ - compoundKey: primaryKey({ + (account) => [ + primaryKey({ columns: [account.provider, account.providerAccountId], }), - userIdIdx: index("account_user_id_idx").on(account.userId), - }) + index("account_user_id_idx").on(account.userId), + ] ); export const sessions = pgTable("session", { @@ -43,9 +43,9 @@ export const sessions = pgTable("session", { .notNull() .references(() => users.id, { onDelete: "cascade" }), expires: timestamp("expires", { mode: "date" }).notNull(), -}, (table) => ({ - userIdIdx: index("session_user_id_idx").on(table.userId), -})); +}, (table) => [ + index("session_user_id_idx").on(table.userId), +]); export const verificationTokens = pgTable( "verificationToken", @@ -54,7 +54,7 @@ export const verificationTokens = pgTable( token: text("token").notNull(), expires: timestamp("expires", { mode: "date" }).notNull(), }, - (vt) => ({ - compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }), - }) + (vt) => [ + primaryKey({ columns: [vt.identifier, vt.token] }), + ] ); \ No newline at end of file diff --git a/packages/db/src/schemas/hackathons.ts b/packages/db/src/schemas/hackathons.ts index c38411b..81456a3 100644 --- a/packages/db/src/schemas/hackathons.ts +++ b/packages/db/src/schemas/hackathons.ts @@ -24,9 +24,9 @@ export const hackathons = pgTable("hackathon", { isPublic: boolean("is_public").notNull().default(true), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - statusIdx: index("hackathon_status_idx").on(table.status), -})); +}, (table) => [ + index("hackathon_status_idx").on(table.status), +]); // Teams for hackathons export const hackathonTeams = pgTable("hackathon_team", { @@ -44,10 +44,10 @@ export const hackathonTeams = pgTable("hackathon_team", { isOpen: boolean("is_open").notNull().default(true), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - hackathonIdIdx: index("team_hackathon_id_idx").on(table.hackathonId), - captainIdIdx: index("team_captain_id_idx").on(table.captainId), -})); +}, (table) => [ + index("team_hackathon_id_idx").on(table.hackathonId), + index("team_captain_id_idx").on(table.captainId), +]); // Individual participants export const hackathonParticipants = pgTable("hackathon_participant", { @@ -82,13 +82,13 @@ export const hackathonParticipants = pgTable("hackathon_participant", { registeredAt: timestamp("registered_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - hackathonIdIdx: index("participant_hackathon_id_idx").on(table.hackathonId), - userIdIdx: index("participant_user_id_idx").on(table.userId), - teamIdIdx: index("participant_team_id_idx").on(table.teamId), +}, (table) => [ + index("participant_hackathon_id_idx").on(table.hackathonId), + index("participant_user_id_idx").on(table.userId), + index("participant_team_id_idx").on(table.teamId), // Compound for quick check "is this user in this hackathon?" - hackathonUserIdx: index("participant_hackathon_user_idx").on(table.hackathonId, table.userId), -})); + index("participant_hackathon_user_idx").on(table.hackathonId, table.userId), +]); // Project submissions export const hackathonProjects = pgTable("hackathon_project", { @@ -113,11 +113,11 @@ export const hackathonProjects = pgTable("hackathon_project", { submittedAt: timestamp("submitted_at"), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - hackathonIdIdx: index("project_hackathon_id_idx").on(table.hackathonId), - teamIdIdx: index("project_team_id_idx").on(table.teamId), - statusIdx: index("project_status_idx").on(table.status), -})); +}, (table) => [ + index("project_hackathon_id_idx").on(table.hackathonId), + index("project_team_id_idx").on(table.teamId), + index("project_status_idx").on(table.status), +]); // Relations export const hackathonsRelations = relations(hackathons, ({ many }) => ({ diff --git a/packages/db/src/schemas/judge.ts b/packages/db/src/schemas/judge.ts index 01bfe36..f984314 100644 --- a/packages/db/src/schemas/judge.ts +++ b/packages/db/src/schemas/judge.ts @@ -14,9 +14,9 @@ export const judges = pgTable("judge", { isActive: boolean("is_active").notNull().default(true), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - userIdIdx: index("judge_user_id_idx").on(table.userId), -})); +}, (table) => [ + index("judge_user_id_idx").on(table.userId), +]); export const judgeAssignments = pgTable("judge_assignment", { id: uuid("id").defaultRandom().primaryKey(), @@ -28,10 +28,10 @@ export const judgeAssignments = pgTable("judge_assignment", { .references(() => hackathons.id, { onDelete: "cascade" }), assignedAt: timestamp("assigned_at").defaultNow().notNull(), isLead: boolean("is_lead").notNull().default(false), -}, (table) => ({ - judgeIdIdx: index("assignment_judge_id_idx").on(table.judgeId), - hackathonIdIdx: index("assignment_hackathon_id_idx").on(table.hackathonId), -})); +}, (table) => [ + index("assignment_judge_id_idx").on(table.judgeId), + index("assignment_hackathon_id_idx").on(table.hackathonId), +]); // Projects with table numbers for judging (extends hackathon projects concept) @@ -48,10 +48,10 @@ export const judgingProjects = pgTable("judging_project", { projectUrl: text("project_url"), repoUrl: text("repo_url"), createdAt: timestamp("created_at").defaultNow().notNull(), -}, (table) => ({ - hackathonIdIdx: index("judging_project_hackathon_id_idx").on(table.hackathonId), - tableNumberIdx: index("judging_project_table_idx").on(table.tableNumber), -})); +}, (table) => [ + index("judging_project_hackathon_id_idx").on(table.hackathonId), + index("judging_project_table_idx").on(table.tableNumber), +]); // Judge votes/scores for projects export const judgeVotes = pgTable("judge_vote", { @@ -72,12 +72,12 @@ export const judgeVotes = pgTable("judge_vote", { comment: text("comment"), votedAt: timestamp("voted_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - judgeIdIdx: index("vote_judge_id_idx").on(table.judgeId), - projectIdIdx: index("vote_project_id_idx").on(table.projectId), +}, (table) => [ + index("vote_judge_id_idx").on(table.judgeId), + index("vote_project_id_idx").on(table.projectId), // Compound to enforce one vote per judge per project (app logic does this, index speeds up check) - uniqueVoteIdx: index("vote_unique_idx").on(table.judgeId, table.projectId), -})); + index("vote_unique_idx").on(table.judgeId, table.projectId), +]); // Map images for hackathon venues export const hackathonMaps = pgTable("hackathon_map", { @@ -89,9 +89,9 @@ export const hackathonMaps = pgTable("hackathon_map", { name: text("name"), order: integer("order").notNull().default(0), createdAt: timestamp("created_at").defaultNow().notNull(), -}, (table) => ({ - hackathonIdIdx: index("map_hackathon_id_idx").on(table.hackathonId), -})); +}, (table) => [ + index("map_hackathon_id_idx").on(table.hackathonId), +]); // Track which tables a judge still needs to visit export const judgeQueue = pgTable("judge_queue", { @@ -108,12 +108,12 @@ export const judgeQueue = pgTable("judge_queue", { order: integer("order").notNull(), // order to visit isCompleted: boolean("is_completed").notNull().default(false), completedAt: timestamp("completed_at"), -}, (table) => ({ - judgeIdIdx: index("queue_judge_id_idx").on(table.judgeId), - hackathonIdIdx: index("queue_hackathon_id_idx").on(table.hackathonId), +}, (table) => [ + index("queue_judge_id_idx").on(table.judgeId), + index("queue_hackathon_id_idx").on(table.hackathonId), // Critical for "next table" logic - todoIdx: index("queue_todo_idx").on(table.judgeId, table.hackathonId, table.isCompleted), -})); + index("queue_todo_idx").on(table.judgeId, table.hackathonId, table.isCompleted), +]); // Relations export const judgesRelations = relations(judges, ({ one, many }) => ({ diff --git a/packages/db/src/schemas/members.ts b/packages/db/src/schemas/members.ts index aa8a03a..a0c6148 100644 --- a/packages/db/src/schemas/members.ts +++ b/packages/db/src/schemas/members.ts @@ -13,9 +13,9 @@ export const userProfiles = pgTable("user_profile", { location: text("location"), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - userIdIdx: index("profile_user_id_idx").on(table.userId), -})); +}, (table) => [ + index("profile_user_id_idx").on(table.userId), +]); export const members = pgTable("member", { id: uuid("id").defaultRandom().primaryKey(), @@ -44,11 +44,11 @@ export const members = pgTable("member", { portfolioUrl: text("portfolio_url"), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - userIdIdx: index("member_user_id_idx").on(table.userId), +}, (table) => [ + index("member_user_id_idx").on(table.userId), // Optimized for "Active Members" directory listing - activeTypeIdx: index("member_active_type_idx").on(table.isActive, table.memberType), -})); + index("member_active_type_idx").on(table.isActive, table.memberType), +]); export const membershipHistory = pgTable("membership_history", { id: uuid("id").defaultRandom().primaryKey(), @@ -60,9 +60,9 @@ export const membershipHistory = pgTable("membership_history", { endDate: timestamp("end_date"), notes: text("notes"), createdAt: timestamp("created_at").defaultNow().notNull(), -}, (table) => ({ - memberIdIdx: index("history_member_id_idx").on(table.memberId), -})); +}, (table) => [ + index("history_member_id_idx").on(table.memberId), +]); export const usersRelations = relations(users, ({ one }) => ({ profile: one(userProfiles, { diff --git a/packages/db/src/schemas/security.ts b/packages/db/src/schemas/security.ts index 4d04120..bc1fd0c 100644 --- a/packages/db/src/schemas/security.ts +++ b/packages/db/src/schemas/security.ts @@ -11,9 +11,9 @@ export const auditLogs = pgTable("audit_logs", { metadata: jsonb("metadata"), severity: securitySeverityEnum("severity").default("info").notNull(), createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(), -}, (table) => ({ - userIdIdx: index("audit_user_id_idx").on(table.userId), - actionIdx: index("audit_action_idx").on(table.action), - createdAtIdx: index("audit_created_at_idx").on(table.createdAt), - severityIdx: index("audit_severity_idx").on(table.severity), -})); +}, (table) => [ + index("audit_user_id_idx").on(table.userId), + index("audit_action_idx").on(table.action), + index("audit_created_at_idx").on(table.createdAt), + index("audit_severity_idx").on(table.severity), +]); diff --git a/packages/db/src/schemas/stripe.ts b/packages/db/src/schemas/stripe.ts index c14a755..8998c4d 100644 --- a/packages/db/src/schemas/stripe.ts +++ b/packages/db/src/schemas/stripe.ts @@ -33,10 +33,10 @@ export const stripePayments = pgTable("stripe_payment", { metadata: text("metadata"), // JSON string for any extra Stripe metadata createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), -}, (table) => ({ - customerEmailIdx: index("stripe_payment_customer_email_idx").on(table.customerEmail), - linkedUserIdIdx: index("stripe_payment_linked_user_id_idx").on(table.linkedUserId), -})); +}, (table) => [ + index("stripe_payment_customer_email_idx").on(table.customerEmail), + index("stripe_payment_linked_user_id_idx").on(table.linkedUserId), +]); /** * Links users who signed in with a different email (e.g., Google) diff --git a/sites/mainweb/components/portal/LinkStripeAccount.tsx b/sites/mainweb/components/portal/LinkStripeAccount.tsx index 21b7f75..837e802 100644 --- a/sites/mainweb/components/portal/LinkStripeAccount.tsx +++ b/sites/mainweb/components/portal/LinkStripeAccount.tsx @@ -57,21 +57,21 @@ export default function LinkStripeAccount({ onSuccess }: LinkStripeAccountProps) }, }); - const payMutation = trpc.stripe.createCheckoutSession.useMutation({ - onSuccess: (data) => { - if (data?.url) { - window.location.href = data.url; - } - }, - onError: (err) => { - setError(err.message); - }, - }); - - const handlePay = () => { - setError(null); - payMutation.mutate({ returnUrl: window.location.href }); - }; + // const payMutation = trpc.stripe.createCheckoutSession.useMutation({ + // onSuccess: (data) => { + // if (data?.url) { + // window.location.href = data.url; + // } + // }, + // onError: (err) => { + // setError(err.message); + // }, + // }); + + // const handlePay = () => { + // setError(null); + // payMutation.mutate({ returnUrl: window.location.href }); + // }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); @@ -137,11 +137,10 @@ export default function LinkStripeAccount({ onSuccess }: LinkStripeAccountProps)