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 0000000..6fd8d0e --- /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 0000000..8337f20 --- /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 b66dc73..ec8f3e0 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 413ded8..9fab352 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] }),