diff --git a/src/app/manage/[clubId]/edit/officers/page.tsx b/src/app/manage/[clubId]/edit/officers/page.tsx index df7955dd..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: 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..30ca549c 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/0009_colossal_omega_flight.sql b/src/server/db/migrations/0009_colossal_omega_flight.sql new file mode 100644 index 00000000..6fd8d0e8 --- /dev/null +++ b/src/server/db/migrations/0009_colossal_omega_flight.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/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/0009_snapshot.json b/src/server/db/migrations/meta/0009_snapshot.json new file mode 100644 index 00000000..cd81cbe6 --- /dev/null +++ b/src/server/db/migrations/meta/0009_snapshot.json @@ -0,0 +1,821 @@ +{ + "version": "5", + "dialect": "pg", + "id": "47b2b0b5-487f-408b-9e3e-1847604c807e", + "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 322fc626..371700fd 100644 --- a/src/server/db/migrations/meta/_journal.json +++ b/src/server/db/migrations/meta/_journal.json @@ -57,6 +57,20 @@ "when": 1712936415961, "tag": "0007_cool_stature", "breakpoints": true + }, + { + "idx": 8, + "version": "5", + "when": 1729719886854, + "tag": "0008_military_mole_man", + "breakpoints": true + }, + { + "idx": 9, + "version": "5", + "when": 1730322465532, + "tag": "0009_colossal_omega_flight", + "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), })); diff --git a/src/server/db/schema/officers.ts b/src/server/db/schema/officers.ts new file mode 100644 index 00000000..594dfb49 --- /dev/null +++ b/src/server/db/schema/officers.ts @@ -0,0 +1,18 @@ +import { relations } from 'drizzle-orm'; +import { pgTable, text, boolean, uuid } from 'drizzle-orm/pg-core'; +import { club } from './club'; + +export const officers = pgTable('officers', { + id: uuid('id').defaultRandom().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] }), +})); 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),