From c4a9da0fab22bc4e757d53d3321a1c29756226e5 Mon Sep 17 00:00:00 2001 From: BK2004 Date: Wed, 23 Oct 2024 16:47:21 -0500 Subject: [PATCH 1/5] Removed title from users -> club relation; Added officers table for listed club officers -- is_president flag for officers that can't be removed --- src/server/db/schema/officers.ts | 24 ++++++++++++++++++++++++ src/server/db/schema/users.ts | 1 - 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/server/db/schema/officers.ts diff --git a/src/server/db/schema/officers.ts b/src/server/db/schema/officers.ts new file mode 100644 index 00000000..dc9ad607 --- /dev/null +++ b/src/server/db/schema/officers.ts @@ -0,0 +1,24 @@ +import { relations } from 'drizzle-orm'; +import { pgTable, text, boolean, primaryKey } from 'drizzle-orm/pg-core'; +import { club } from './club'; + +export const officers = pgTable( + 'officers', + { + id: text('id').notNull(), + clubId: text('club_id') + .notNull() + .references(() => club.id), + name: text('name').notNull(), + position: text('position').notNull(), + image: text('image').default('/nebula-logo.png').notNull(), + isPresident: boolean('is_president').default(false).notNull(), + }, + (table) => ({ + pk: primaryKey(table.clubId, table.id), + }) +); + +export const officersToClubs = relations(officers, ({ one }) => ({ + club: one(club, { fields: [officers.clubId], references: [club.id] }), +})); \ No newline at end of file diff --git a/src/server/db/schema/users.ts b/src/server/db/schema/users.ts index 1da47684..c1c7e1f9 100644 --- a/src/server/db/schema/users.ts +++ b/src/server/db/schema/users.ts @@ -117,7 +117,6 @@ export const userMetadataToClubs = pgTable( memberType: clubRoleEnum('member_type') .$default(() => 'Member') .notNull(), - title: text('title'), }, (t) => ({ pk: primaryKey(t.userId, t.clubId), From 5529a6e1ac425d10918c12045d395e993a8cc4eb Mon Sep 17 00:00:00 2001 From: BK2004 Date: Wed, 23 Oct 2024 17:04:50 -0500 Subject: [PATCH 2/5] Removed userMetadataToClubs title dependencies; added db migration --- .../manage/[clubId]/edit/officers/page.tsx | 2 +- .../club/listing/ClubInfoSegment.tsx | 2 +- src/server/api/routers/clubEdit.ts | 33 +- .../db/migrations/0008_military_mole_man.sql | 16 + .../db/migrations/meta/0008_snapshot.json | 828 ++++++++++++++++++ src/server/db/migrations/meta/_journal.json | 7 + src/server/db/schema/club.ts | 2 + 7 files changed, 872 insertions(+), 18 deletions(-) create mode 100644 src/server/db/migrations/0008_military_mole_man.sql create mode 100644 src/server/db/migrations/meta/0008_snapshot.json diff --git a/src/app/manage/[clubId]/edit/officers/page.tsx b/src/app/manage/[clubId]/edit/officers/page.tsx index df7955dd..6b7817aa 100644 --- a/src/app/manage/[clubId]/edit/officers/page.tsx +++ b/src/app/manage/[clubId]/edit/officers/page.tsx @@ -21,7 +21,7 @@ export default async function Page({ name: officer.userMetadata.firstName + ' ' + officer.userMetadata.lastName, locked: officer.memberType == 'President' || role == 'Officer', position: officer.memberType as 'President' | 'Officer', - title: officer.title as string, + title: "", // TODO: link from officers table })); return ( diff --git a/src/components/club/listing/ClubInfoSegment.tsx b/src/components/club/listing/ClubInfoSegment.tsx index d1fe1fc7..1654ea64 100644 --- a/src/components/club/listing/ClubInfoSegment.tsx +++ b/src/components/club/listing/ClubInfoSegment.tsx @@ -73,7 +73,7 @@ const ClubInfoSegment: FC<{ officer.userMetadata.lastName}

- {officer.title ?? 'Officer'} + Officer {/* TODO: link to officers table */}

diff --git a/src/server/api/routers/clubEdit.ts b/src/server/api/routers/clubEdit.ts index 03a5fb20..67b21e47 100644 --- a/src/server/api/routers/clubEdit.ts +++ b/src/server/api/routers/clubEdit.ts @@ -1,6 +1,6 @@ import { db } from '@src/server/db'; import { createTRPCRouter, protectedProcedure } from '../trpc'; -import { and, eq, inArray, sql } from 'drizzle-orm'; +import { and, eq, inArray } from 'drizzle-orm'; import { editClubSchema } from '@src/utils/formSchemas'; import { TRPCError } from '@trpc/server'; import { z } from 'zod'; @@ -136,20 +136,21 @@ export const clubEditRouter = createTRPCRouter({ ), ); } - const promises: Promise[] = []; - for (const modded of input.modified) { - const prom = ctx.db - .update(userMetadataToClubs) - .set({ title: modded.title }) - .where( - and( - eq(userMetadataToClubs.userId, modded.userId), - eq(userMetadataToClubs.clubId, input.clubId), - ), - ); - promises.push(prom); - } - await Promise.allSettled(promises); + // TODO: link to officers table + // const promises: Promise[] = []; + // for (const modded of input.modified) { + // const prom = ctx.db + // .update(userMetadataToClubs) + // .set({ title: modded.title }) + // .where( + // and( + // eq(userMetadataToClubs.userId, modded.userId), + // eq(userMetadataToClubs.clubId, input.clubId), + // ), + // ); + // promises.push(prom); + // } + // await Promise.allSettled(promises); if (input.created.length === 0) return; await ctx.db @@ -164,7 +165,7 @@ export const clubEditRouter = createTRPCRouter({ ) .onConflictDoUpdate({ target: [userMetadataToClubs.userId, userMetadataToClubs.clubId], - set: { memberType: 'Officer' as const, title: sql`excluded.title` }, + set: { memberType: 'Officer' as const}, where: eq(userMetadataToClubs.memberType, 'Member'), }); }), diff --git a/src/server/db/migrations/0008_military_mole_man.sql b/src/server/db/migrations/0008_military_mole_man.sql new file mode 100644 index 00000000..f2751de0 --- /dev/null +++ b/src/server/db/migrations/0008_military_mole_man.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS "officers" ( + "id" text NOT NULL, + "club_id" text NOT NULL, + "name" text NOT NULL, + "position" text NOT NULL, + "image" text DEFAULT '/nebula-logo.png' NOT NULL, + "is_president" boolean DEFAULT false NOT NULL, + CONSTRAINT officers_club_id_id PRIMARY KEY("club_id","id") +); +--> statement-breakpoint +ALTER TABLE "user_metadata_to_clubs" DROP COLUMN IF EXISTS "title";--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "officers" ADD CONSTRAINT "officers_club_id_club_id_fk" FOREIGN KEY ("club_id") REFERENCES "club"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/src/server/db/migrations/meta/0008_snapshot.json b/src/server/db/migrations/meta/0008_snapshot.json new file mode 100644 index 00000000..2c2337b6 --- /dev/null +++ b/src/server/db/migrations/meta/0008_snapshot.json @@ -0,0 +1,828 @@ +{ + "version": "5", + "dialect": "pg", + "id": "48d235dc-83ee-48ae-bad8-dc3e7093cdd1", + "prevId": "429d44fa-511e-4cb4-89bb-aae0f8d67bdb", + "tables": { + "admin": { + "name": "admin", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "admin_userId_user_metadata_id_fk": { + "name": "admin_userId_user_metadata_id_fk", + "tableFrom": "admin", + "tableTo": "user_metadata", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "carousel": { + "name": "carousel", + "schema": "", + "columns": { + "orgId": { + "name": "orgId", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "startTime": { + "name": "startTime", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "endTime": { + "name": "endTime", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "carousel_orgId_club_id_fk": { + "name": "carousel_orgId_club_id_fk", + "tableFrom": "carousel", + "tableTo": "club", + "columnsFrom": [ + "orgId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "club": { + "name": "club", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'/nebula-logo.png'" + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "approved": { + "name": "approved", + "type": "approved_enum", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "profile_image": { + "name": "profile_image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "soc": { + "name": "soc", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "contacts": { + "name": "contacts", + "schema": "", + "columns": { + "platform": { + "name": "platform", + "type": "platform", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "contacts_club_id_club_id_fk": { + "name": "contacts_club_id_club_id_fk", + "tableFrom": "contacts", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "contacts_platform_club_id": { + "name": "contacts_platform_club_id", + "columns": [ + "platform", + "club_id" + ] + } + }, + "uniqueConstraints": {} + }, + "events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": {}, + "foreignKeys": { + "events_club_id_club_id_fk": { + "name": "events_club_id_club_id_fk", + "tableFrom": "events", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "feedback_form": { + "name": "feedback_form", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "likes": { + "name": "likes", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dislikes": { + "name": "dislikes", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "features": { + "name": "features", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "submit_on": { + "name": "submit_on", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "officers": { + "name": "officers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'/nebula-logo.png'" + }, + "is_president": { + "name": "is_president", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "officers_club_id_club_id_fk": { + "name": "officers_club_id_club_id_fk", + "tableFrom": "officers", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "officers_club_id_id": { + "name": "officers_club_id_id", + "columns": [ + "club_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "account": { + "name": "account", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "providerAccountId": { + "name": "providerAccountId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "account_userId_user_id_fk": { + "name": "account_userId_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "account_provider_providerAccountId": { + "name": "account_provider_providerAccountId", + "columns": [ + "provider", + "providerAccountId" + ] + } + }, + "uniqueConstraints": {} + }, + "session": { + "name": "session", + "schema": "", + "columns": { + "sessionToken": { + "name": "sessionToken", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_userId_user_id_fk": { + "name": "session_userId_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_metadata": { + "name": "user_metadata", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "major": { + "name": "major", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "minor": { + "name": "minor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "year": { + "name": "year", + "type": "year", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "role", + "primaryKey": false, + "notNull": true + }, + "career": { + "name": "career", + "type": "career", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_metadata_to_clubs": { + "name": "user_metadata_to_clubs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "member_type": { + "name": "member_type", + "type": "member_type", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_metadata_to_clubs_user_id_user_metadata_id_fk": { + "name": "user_metadata_to_clubs_user_id_user_metadata_id_fk", + "tableFrom": "user_metadata_to_clubs", + "tableTo": "user_metadata", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_metadata_to_clubs_club_id_club_id_fk": { + "name": "user_metadata_to_clubs_club_id_club_id_fk", + "tableFrom": "user_metadata_to_clubs", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_metadata_to_clubs_user_id_club_id": { + "name": "user_metadata_to_clubs_user_id_club_id", + "columns": [ + "user_id", + "club_id" + ] + } + }, + "uniqueConstraints": {} + }, + "user_metadata_to_events": { + "name": "user_metadata_to_events", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_metadata_to_events_user_id_user_id_fk": { + "name": "user_metadata_to_events_user_id_user_id_fk", + "tableFrom": "user_metadata_to_events", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_metadata_to_events_event_id_events_id_fk": { + "name": "user_metadata_to_events_event_id_events_id_fk", + "tableFrom": "user_metadata_to_events", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_metadata_to_events_user_id_event_id": { + "name": "user_metadata_to_events_user_id_event_id", + "columns": [ + "user_id", + "event_id" + ] + } + }, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "emailVerified": { + "name": "emailVerified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "verificationToken": { + "name": "verificationToken", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verificationToken_identifier_token": { + "name": "verificationToken_identifier_token", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": { + "approved_enum": { + "name": "approved_enum", + "values": { + "approved": "approved", + "rejected": "rejected", + "pending": "pending" + } + }, + "career": { + "name": "career", + "values": { + "Healthcare": "Healthcare", + "Art and Music": "Art and Music", + "Engineering": "Engineering", + "Business": "Business", + "Sciences": "Sciences", + "Public Service": "Public Service" + } + }, + "member_type": { + "name": "member_type", + "values": { + "President": "President", + "Officer": "Officer", + "Member": "Member" + } + }, + "role": { + "name": "role", + "values": { + "Student": "Student", + "Student Organizer": "Student Organizer", + "Administrator": "Administrator" + } + }, + "year": { + "name": "year", + "values": { + "Freshman": "Freshman", + "Sophomore": "Sophomore", + "Junior": "Junior", + "Senior": "Senior", + "Grad Student": "Grad Student" + } + } + }, + "schemas": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/src/server/db/migrations/meta/_journal.json b/src/server/db/migrations/meta/_journal.json index 322fc626..b66dc73f 100644 --- a/src/server/db/migrations/meta/_journal.json +++ b/src/server/db/migrations/meta/_journal.json @@ -57,6 +57,13 @@ "when": 1712936415961, "tag": "0007_cool_stature", "breakpoints": true + }, + { + "idx": 8, + "version": "5", + "when": 1729719886854, + "tag": "0008_military_mole_man", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/server/db/schema/club.ts b/src/server/db/schema/club.ts index 52f632c4..87ca99e0 100644 --- a/src/server/db/schema/club.ts +++ b/src/server/db/schema/club.ts @@ -11,6 +11,7 @@ import { events } from './events'; import { userMetadataToClubs } from './users'; import { contacts } from './contacts'; import { carousel } from './admin'; +import { officers } from './officers'; export const approvedEnum = pgEnum('approved_enum', [ 'approved', @@ -39,6 +40,7 @@ export const club = pgTable('club', { export const clubRelations = relations(club, ({ many }) => ({ contacts: many(contacts), events: many(events), + officers: many(officers), userMetadataToClubs: many(userMetadataToClubs), carousel: many(carousel), })); From 19b91879931c7c8295372fd57122303163bc14c8 Mon Sep 17 00:00:00 2001 From: BK2004 Date: Wed, 23 Oct 2024 17:30:08 -0500 Subject: [PATCH 3/5] prettier formatting --- .../manage/[clubId]/edit/officers/page.tsx | 2 +- src/server/api/routers/clubEdit.ts | 2 +- src/server/db/schema/officers.ts | 32 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/app/manage/[clubId]/edit/officers/page.tsx b/src/app/manage/[clubId]/edit/officers/page.tsx index 6b7817aa..984253d3 100644 --- a/src/app/manage/[clubId]/edit/officers/page.tsx +++ b/src/app/manage/[clubId]/edit/officers/page.tsx @@ -21,7 +21,7 @@ export default async function Page({ name: officer.userMetadata.firstName + ' ' + officer.userMetadata.lastName, locked: officer.memberType == 'President' || role == 'Officer', position: officer.memberType as 'President' | 'Officer', - title: "", // TODO: link from officers table + title: '', // TODO: link from officers table })); return ( diff --git a/src/server/api/routers/clubEdit.ts b/src/server/api/routers/clubEdit.ts index 67b21e47..30ca549c 100644 --- a/src/server/api/routers/clubEdit.ts +++ b/src/server/api/routers/clubEdit.ts @@ -165,7 +165,7 @@ export const clubEditRouter = createTRPCRouter({ ) .onConflictDoUpdate({ target: [userMetadataToClubs.userId, userMetadataToClubs.clubId], - set: { memberType: 'Officer' as const}, + set: { memberType: 'Officer' as const }, where: eq(userMetadataToClubs.memberType, 'Member'), }); }), diff --git a/src/server/db/schema/officers.ts b/src/server/db/schema/officers.ts index dc9ad607..413ded84 100644 --- a/src/server/db/schema/officers.ts +++ b/src/server/db/schema/officers.ts @@ -3,22 +3,22 @@ import { pgTable, text, boolean, primaryKey } from 'drizzle-orm/pg-core'; import { club } from './club'; export const officers = pgTable( - 'officers', - { - id: text('id').notNull(), - clubId: text('club_id') - .notNull() - .references(() => club.id), - name: text('name').notNull(), - position: text('position').notNull(), - image: text('image').default('/nebula-logo.png').notNull(), - isPresident: boolean('is_president').default(false).notNull(), - }, - (table) => ({ - pk: primaryKey(table.clubId, table.id), - }) + 'officers', + { + id: text('id').notNull(), + clubId: text('club_id') + .notNull() + .references(() => club.id), + name: text('name').notNull(), + position: text('position').notNull(), + image: text('image').default('/nebula-logo.png').notNull(), + isPresident: boolean('is_president').default(false).notNull(), + }, + (table) => ({ + pk: primaryKey(table.clubId, table.id), + }), ); export const officersToClubs = relations(officers, ({ one }) => ({ - club: one(club, { fields: [officers.clubId], references: [club.id] }), -})); \ No newline at end of file + club: one(club, { fields: [officers.clubId], references: [club.id] }), +})); From 24903aa6c908f3fa8a514fafbe585dbd4546338c Mon Sep 17 00:00:00 2001 From: BK2004 Date: Tue, 29 Oct 2024 19:01:42 -0500 Subject: [PATCH 4/5] Removed composite key for officers id and clubId; gave officer id a default as uuid --- .../db/migrations/0009_unknown_mastermind.sql | 4 + .../db/migrations/meta/0009_snapshot.json | 821 ++++++++++++++++++ src/server/db/migrations/meta/_journal.json | 7 + src/server/db/schema/officers.ts | 28 +- 4 files changed, 843 insertions(+), 17 deletions(-) create mode 100644 src/server/db/migrations/0009_unknown_mastermind.sql create mode 100644 src/server/db/migrations/meta/0009_snapshot.json diff --git a/src/server/db/migrations/0009_unknown_mastermind.sql b/src/server/db/migrations/0009_unknown_mastermind.sql new file mode 100644 index 00000000..6fd8d0e8 --- /dev/null +++ b/src/server/db/migrations/0009_unknown_mastermind.sql @@ -0,0 +1,4 @@ +ALTER TABLE "officers" DROP CONSTRAINT "officers_club_id_id";--> statement-breakpoint +ALTER TABLE "officers" ADD PRIMARY KEY ("id");--> statement-breakpoint +ALTER TABLE "officers" ALTER COLUMN "id" SET DATA TYPE uuid;--> statement-breakpoint +ALTER TABLE "officers" ALTER COLUMN "id" SET DEFAULT gen_random_uuid(); \ No newline at end of file diff --git a/src/server/db/migrations/meta/0009_snapshot.json b/src/server/db/migrations/meta/0009_snapshot.json new file mode 100644 index 00000000..8337f20e --- /dev/null +++ b/src/server/db/migrations/meta/0009_snapshot.json @@ -0,0 +1,821 @@ +{ + "version": "5", + "dialect": "pg", + "id": "cc00cb68-4c57-4578-9141-b7fb0fcf8710", + "prevId": "48d235dc-83ee-48ae-bad8-dc3e7093cdd1", + "tables": { + "admin": { + "name": "admin", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "admin_userId_user_metadata_id_fk": { + "name": "admin_userId_user_metadata_id_fk", + "tableFrom": "admin", + "tableTo": "user_metadata", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "carousel": { + "name": "carousel", + "schema": "", + "columns": { + "orgId": { + "name": "orgId", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "startTime": { + "name": "startTime", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "endTime": { + "name": "endTime", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "carousel_orgId_club_id_fk": { + "name": "carousel_orgId_club_id_fk", + "tableFrom": "carousel", + "tableTo": "club", + "columnsFrom": [ + "orgId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "club": { + "name": "club", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'/nebula-logo.png'" + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "approved": { + "name": "approved", + "type": "approved_enum", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "profile_image": { + "name": "profile_image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "soc": { + "name": "soc", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "contacts": { + "name": "contacts", + "schema": "", + "columns": { + "platform": { + "name": "platform", + "type": "platform", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "contacts_club_id_club_id_fk": { + "name": "contacts_club_id_club_id_fk", + "tableFrom": "contacts", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "contacts_platform_club_id": { + "name": "contacts_platform_club_id", + "columns": [ + "platform", + "club_id" + ] + } + }, + "uniqueConstraints": {} + }, + "events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": {}, + "foreignKeys": { + "events_club_id_club_id_fk": { + "name": "events_club_id_club_id_fk", + "tableFrom": "events", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "feedback_form": { + "name": "feedback_form", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "nanoid(20)" + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "likes": { + "name": "likes", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "dislikes": { + "name": "dislikes", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "features": { + "name": "features", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "submit_on": { + "name": "submit_on", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "officers": { + "name": "officers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'/nebula-logo.png'" + }, + "is_president": { + "name": "is_president", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "officers_club_id_club_id_fk": { + "name": "officers_club_id_club_id_fk", + "tableFrom": "officers", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "account": { + "name": "account", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "providerAccountId": { + "name": "providerAccountId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "account_userId_user_id_fk": { + "name": "account_userId_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "account_provider_providerAccountId": { + "name": "account_provider_providerAccountId", + "columns": [ + "provider", + "providerAccountId" + ] + } + }, + "uniqueConstraints": {} + }, + "session": { + "name": "session", + "schema": "", + "columns": { + "sessionToken": { + "name": "sessionToken", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_userId_user_id_fk": { + "name": "session_userId_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_metadata": { + "name": "user_metadata", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "major": { + "name": "major", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "minor": { + "name": "minor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "year": { + "name": "year", + "type": "year", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "role", + "primaryKey": false, + "notNull": true + }, + "career": { + "name": "career", + "type": "career", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_metadata_to_clubs": { + "name": "user_metadata_to_clubs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "club_id": { + "name": "club_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "member_type": { + "name": "member_type", + "type": "member_type", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_metadata_to_clubs_user_id_user_metadata_id_fk": { + "name": "user_metadata_to_clubs_user_id_user_metadata_id_fk", + "tableFrom": "user_metadata_to_clubs", + "tableTo": "user_metadata", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_metadata_to_clubs_club_id_club_id_fk": { + "name": "user_metadata_to_clubs_club_id_club_id_fk", + "tableFrom": "user_metadata_to_clubs", + "tableTo": "club", + "columnsFrom": [ + "club_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_metadata_to_clubs_user_id_club_id": { + "name": "user_metadata_to_clubs_user_id_club_id", + "columns": [ + "user_id", + "club_id" + ] + } + }, + "uniqueConstraints": {} + }, + "user_metadata_to_events": { + "name": "user_metadata_to_events", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_metadata_to_events_user_id_user_id_fk": { + "name": "user_metadata_to_events_user_id_user_id_fk", + "tableFrom": "user_metadata_to_events", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_metadata_to_events_event_id_events_id_fk": { + "name": "user_metadata_to_events_event_id_events_id_fk", + "tableFrom": "user_metadata_to_events", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_metadata_to_events_user_id_event_id": { + "name": "user_metadata_to_events_user_id_event_id", + "columns": [ + "user_id", + "event_id" + ] + } + }, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "emailVerified": { + "name": "emailVerified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "verificationToken": { + "name": "verificationToken", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verificationToken_identifier_token": { + "name": "verificationToken_identifier_token", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": { + "approved_enum": { + "name": "approved_enum", + "values": { + "approved": "approved", + "rejected": "rejected", + "pending": "pending" + } + }, + "career": { + "name": "career", + "values": { + "Healthcare": "Healthcare", + "Art and Music": "Art and Music", + "Engineering": "Engineering", + "Business": "Business", + "Sciences": "Sciences", + "Public Service": "Public Service" + } + }, + "member_type": { + "name": "member_type", + "values": { + "President": "President", + "Officer": "Officer", + "Member": "Member" + } + }, + "role": { + "name": "role", + "values": { + "Student": "Student", + "Student Organizer": "Student Organizer", + "Administrator": "Administrator" + } + }, + "year": { + "name": "year", + "values": { + "Freshman": "Freshman", + "Sophomore": "Sophomore", + "Junior": "Junior", + "Senior": "Senior", + "Grad Student": "Grad Student" + } + } + }, + "schemas": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/src/server/db/migrations/meta/_journal.json b/src/server/db/migrations/meta/_journal.json index b66dc73f..ec8f3e03 100644 --- a/src/server/db/migrations/meta/_journal.json +++ b/src/server/db/migrations/meta/_journal.json @@ -64,6 +64,13 @@ "when": 1729719886854, "tag": "0008_military_mole_man", "breakpoints": true + }, + { + "idx": 9, + "version": "5", + "when": 1730246133518, + "tag": "0009_unknown_mastermind", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/server/db/schema/officers.ts b/src/server/db/schema/officers.ts index 413ded84..9fab352a 100644 --- a/src/server/db/schema/officers.ts +++ b/src/server/db/schema/officers.ts @@ -1,23 +1,17 @@ import { relations } from 'drizzle-orm'; -import { pgTable, text, boolean, primaryKey } from 'drizzle-orm/pg-core'; +import { pgTable, text, boolean, uuid } from 'drizzle-orm/pg-core'; import { club } from './club'; -export const officers = pgTable( - 'officers', - { - id: text('id').notNull(), - clubId: text('club_id') - .notNull() - .references(() => club.id), - name: text('name').notNull(), - position: text('position').notNull(), - image: text('image').default('/nebula-logo.png').notNull(), - isPresident: boolean('is_president').default(false).notNull(), - }, - (table) => ({ - pk: primaryKey(table.clubId, table.id), - }), -); +export const officers = pgTable('officers', { + id: uuid('id').defaultRandom().notNull().primaryKey(), + clubId: text('club_id') + .notNull() + .references(() => club.id), + name: text('name').notNull(), + position: text('position').notNull(), + image: text('image').default('/nebula-logo.png').notNull(), + isPresident: boolean('is_president').default(false).notNull(), +}); export const officersToClubs = relations(officers, ({ one }) => ({ club: one(club, { fields: [officers.clubId], references: [club.id] }), From a9d523c20e11dfb4e4c50f9dad091e154cb40c54 Mon Sep 17 00:00:00 2001 From: BK2004 Date: Wed, 30 Oct 2024 16:09:18 -0500 Subject: [PATCH 5/5] removed unnecessary notNull --- ..._unknown_mastermind.sql => 0009_colossal_omega_flight.sql} | 0 src/server/db/migrations/meta/0009_snapshot.json | 2 +- src/server/db/migrations/meta/_journal.json | 4 ++-- src/server/db/schema/officers.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename src/server/db/migrations/{0009_unknown_mastermind.sql => 0009_colossal_omega_flight.sql} (100%) diff --git a/src/server/db/migrations/0009_unknown_mastermind.sql b/src/server/db/migrations/0009_colossal_omega_flight.sql similarity index 100% rename from src/server/db/migrations/0009_unknown_mastermind.sql rename to src/server/db/migrations/0009_colossal_omega_flight.sql diff --git a/src/server/db/migrations/meta/0009_snapshot.json b/src/server/db/migrations/meta/0009_snapshot.json index 8337f20e..cd81cbe6 100644 --- a/src/server/db/migrations/meta/0009_snapshot.json +++ b/src/server/db/migrations/meta/0009_snapshot.json @@ -1,7 +1,7 @@ { "version": "5", "dialect": "pg", - "id": "cc00cb68-4c57-4578-9141-b7fb0fcf8710", + "id": "47b2b0b5-487f-408b-9e3e-1847604c807e", "prevId": "48d235dc-83ee-48ae-bad8-dc3e7093cdd1", "tables": { "admin": { diff --git a/src/server/db/migrations/meta/_journal.json b/src/server/db/migrations/meta/_journal.json index ec8f3e03..371700fd 100644 --- a/src/server/db/migrations/meta/_journal.json +++ b/src/server/db/migrations/meta/_journal.json @@ -68,8 +68,8 @@ { "idx": 9, "version": "5", - "when": 1730246133518, - "tag": "0009_unknown_mastermind", + "when": 1730322465532, + "tag": "0009_colossal_omega_flight", "breakpoints": true } ] diff --git a/src/server/db/schema/officers.ts b/src/server/db/schema/officers.ts index 9fab352a..594dfb49 100644 --- a/src/server/db/schema/officers.ts +++ b/src/server/db/schema/officers.ts @@ -3,7 +3,7 @@ import { pgTable, text, boolean, uuid } from 'drizzle-orm/pg-core'; import { club } from './club'; export const officers = pgTable('officers', { - id: uuid('id').defaultRandom().notNull().primaryKey(), + id: uuid('id').defaultRandom().primaryKey(), clubId: text('club_id') .notNull() .references(() => club.id),