diff --git a/package-lock.json b/package-lock.json index 8e3e5e7d..2f29eb8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@fullcalendar/react": "^6.0.2", "@fullcalendar/timegrid": "^6.0.2", "@next-auth/prisma-adapter": "^1.0.4", - "@prisma/client": "^4.8.0", + "@prisma/client": "^5.5.2", "@sendgrid/mail": "^7.7.0", "@syncfusion/ej2-react-schedule": "^20.4.43", "@tanstack/react-query": "^4.35.7", @@ -61,7 +61,7 @@ "postcss": "^8.4.16", "prettier": "^2.8.2", "prettier-plugin-tailwindcss": "^0.1.13", - "prisma": "^4.8.0", + "prisma": "^5.5.2", "tailwindcss": "^3.1.8", "typescript": "4.7.4" } @@ -822,15 +822,15 @@ } }, "node_modules/@prisma/client": { - "version": "4.16.2", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.16.2.tgz", - "integrity": "sha512-qCoEyxv1ZrQ4bKy39GnylE8Zq31IRmm8bNhNbZx7bF2cU5aiCCnSa93J2imF88MBjn7J9eUQneNxUQVJdl/rPQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.5.2.tgz", + "integrity": "sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==", "hasInstallScript": true, "dependencies": { - "@prisma/engines-version": "4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81" + "@prisma/engines-version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a" }, "engines": { - "node": ">=14.17" + "node": ">=16.13" }, "peerDependencies": { "prisma": "*" @@ -842,16 +842,16 @@ } }, "node_modules/@prisma/engines": { - "version": "4.16.2", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.16.2.tgz", - "integrity": "sha512-vx1nxVvN4QeT/cepQce68deh/Turxy5Mr+4L4zClFuK1GlxN3+ivxfuv+ej/gvidWn1cE1uAhW7ALLNlYbRUAw==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.5.2.tgz", + "integrity": "sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==", "dev": true, "hasInstallScript": true }, "node_modules/@prisma/engines-version": { - "version": "4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81.tgz", - "integrity": "sha512-q617EUWfRIDTriWADZ4YiWRZXCa/WuhNgLTVd+HqWLffjMSPzyM5uOWoauX91wvQClSKZU4pzI4JJLQ9Kl62Qg==" + "version": "5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a.tgz", + "integrity": "sha512-O+qHFnZvAyOFk1tUco2/VdiqS0ym42a3+6CYLScllmnpbyiTplgyLt2rK/B9BTjYkSHjrgMhkG47S0oqzdIckA==" }, "node_modules/@rushstack/eslint-patch": { "version": "1.3.3", @@ -4899,20 +4899,19 @@ "integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==" }, "node_modules/prisma": { - "version": "4.16.2", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.16.2.tgz", - "integrity": "sha512-SYCsBvDf0/7XSJyf2cHTLjLeTLVXYfqp7pG5eEVafFLeT0u/hLFz/9W196nDRGUOo1JfPatAEb+uEnTQImQC1g==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.5.2.tgz", + "integrity": "sha512-WQtG6fevOL053yoPl6dbHV+IWgKo25IRN4/pwAGqcWmg7CrtoCzvbDbN9fXUc7QS2KK0LimHIqLsaCOX/vHl8w==", "dev": true, "hasInstallScript": true, "dependencies": { - "@prisma/engines": "4.16.2" + "@prisma/engines": "5.5.2" }, "bin": { - "prisma": "build/index.js", - "prisma2": "build/index.js" + "prisma": "build/index.js" }, "engines": { - "node": ">=14.17" + "node": ">=16.13" } }, "node_modules/prisma-generate": { diff --git a/package.json b/package.json index b7b9a64c..6468e99f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@fullcalendar/react": "^6.0.2", "@fullcalendar/timegrid": "^6.0.2", "@next-auth/prisma-adapter": "^1.0.4", - "@prisma/client": "^4.8.0", + "@prisma/client": "^5.5.2", "@sendgrid/mail": "^7.7.0", "@syncfusion/ej2-react-schedule": "^20.4.43", "@tanstack/react-query": "^4.35.7", @@ -64,7 +64,7 @@ "postcss": "^8.4.16", "prettier": "^2.8.2", "prettier-plugin-tailwindcss": "^0.1.13", - "prisma": "^4.8.0", + "prisma": "^5.5.2", "tailwindcss": "^3.1.8", "typescript": "4.7.4" }, diff --git a/prisma/migrations/0_init/migration.sql b/prisma/migrations/0_init/migration.sql new file mode 100644 index 00000000..49377975 --- /dev/null +++ b/prisma/migrations/0_init/migration.sql @@ -0,0 +1,115 @@ +-- CreateEnum +CREATE TYPE "Role" AS ENUM ('HACKER', 'ADMIN', 'REVIEWER', 'FOOD_MANAGER', 'EVENT_MANAGER', 'GENERAL_SCANNER', 'SPONSER'); + +-- CreateEnum +CREATE TYPE "Status" AS ENUM ('IN_REVIEW', 'REJECTED', 'WAITLISTED', 'ACCEPTED', 'RSVP', 'CHECKED_IN'); + +-- CreateTable +CREATE TABLE "Account" ( + "id" STRING NOT NULL, + "userId" STRING NOT NULL, + "type" STRING NOT NULL, + "provider" STRING NOT NULL, + "providerAccountId" STRING NOT NULL, + "refresh_token" STRING, + "refresh_token_expires_in" INT4, + "access_token" STRING, + "expires_at" INT4, + "ext_expires_in" INT4, + "oauth_token_secret" STRING, + "oauth_token" STRING, + "token_type" STRING, + "scope" STRING, + "id_token" STRING, + "session_state" STRING, + + CONSTRAINT "Account_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Session" ( + "id" STRING NOT NULL, + "sessionToken" STRING NOT NULL, + "userId" STRING NOT NULL, + "expires" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Session_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "User" ( + "id" STRING NOT NULL, + "name" STRING, + "email" STRING, + "emailVerified" TIMESTAMP(3), + "image" STRING, + "typeform_response_id" STRING, + "role" "Role"[] DEFAULT ARRAY['HACKER']::"Role"[], + "status" "Status" NOT NULL DEFAULT 'IN_REVIEW', + "qrcode" INT4, + "mealsTaken" INT4 NOT NULL DEFAULT 0, + "lastMealTaken" TIMESTAMP(3), + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Review" ( + "id" STRING NOT NULL, + "hackerId" STRING NOT NULL, + "reviewerId" STRING NOT NULL, + "mark" FLOAT8 NOT NULL DEFAULT 0, + + CONSTRAINT "Review_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "EventLog" ( + "id" STRING NOT NULL, + "userId" STRING NOT NULL, + "timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "event" STRING NOT NULL, + + CONSTRAINT "EventLog_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "VerificationToken" ( + "identifier" STRING NOT NULL, + "token" STRING NOT NULL, + "expires" TIMESTAMP(3) NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_qrcode_key" ON "User"("qrcode"); + +-- CreateIndex +CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token"); + +-- CreateIndex +CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); + +-- AddForeignKey +ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Review" ADD CONSTRAINT "Review_hackerId_fkey" FOREIGN KEY ("hackerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Review" ADD CONSTRAINT "Review_reviewerId_fkey" FOREIGN KEY ("reviewerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "EventLog" ADD CONSTRAINT "EventLog_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/prisma/migrations/20221112203343_initial_migration/migration.sql b/prisma/migrations/20221112203343_initial_migration/migration.sql deleted file mode 100644 index 83802801..00000000 --- a/prisma/migrations/20221112203343_initial_migration/migration.sql +++ /dev/null @@ -1,77 +0,0 @@ --- CreateTable -CREATE TABLE "Example" ( - "id" TEXT NOT NULL, - - CONSTRAINT "Example_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Account" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "provider" TEXT NOT NULL, - "providerAccountId" TEXT NOT NULL, - "refresh_token" TEXT, - "refresh_token_expires_in" INTEGER, - "access_token" TEXT, - "expires_at" INTEGER, - "oauth_token_secret" TEXT, - "oauth_token" TEXT, - "token_type" TEXT, - "scope" TEXT, - "id_token" TEXT, - "session_state" TEXT, - - CONSTRAINT "Account_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Session" ( - "id" TEXT NOT NULL, - "sessionToken" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "expires" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Session_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL, - "name" TEXT, - "email" TEXT, - "emailVerified" TIMESTAMP(3), - "image" TEXT, - "typeform_response_id" TEXT, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "VerificationToken" ( - "identifier" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expires" TIMESTAMP(3) NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId"); - --- CreateIndex -CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken"); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token"); - --- CreateIndex -CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); - --- AddForeignKey -ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20221112204243_add_roles/migration.sql b/prisma/migrations/20221112204243_add_roles/migration.sql deleted file mode 100644 index 16f2cc1f..00000000 --- a/prisma/migrations/20221112204243_add_roles/migration.sql +++ /dev/null @@ -1,14 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Example` table. If the table is not empty, all the data it contains will be lost. - -*/ --- CreateEnum -CREATE TYPE "Role" AS ENUM ('HACKER', 'ADMIN', 'REVIEWER'); - --- AlterTable -ALTER TABLE "User" ADD COLUMN "role" "Role"[] DEFAULT ARRAY['HACKER']::"Role"[]; - --- DropTable -DROP TABLE "Example"; diff --git a/prisma/migrations/20221115184153_add_reviews/migration.sql b/prisma/migrations/20221115184153_add_reviews/migration.sql deleted file mode 100644 index 6a54b76e..00000000 --- a/prisma/migrations/20221115184153_add_reviews/migration.sql +++ /dev/null @@ -1,15 +0,0 @@ --- CreateTable -CREATE TABLE "Review" ( - "id" TEXT NOT NULL, - "hackerId" TEXT NOT NULL, - "reviewerId" TEXT NOT NULL, - "mark" DOUBLE PRECISION NOT NULL DEFAULT 0, - - CONSTRAINT "Review_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "Review" ADD CONSTRAINT "Review_hackerId_fkey" FOREIGN KEY ("hackerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Review" ADD CONSTRAINT "Review_reviewerId_fkey" FOREIGN KEY ("reviewerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230104055428_add_statuses/migration.sql b/prisma/migrations/20230104055428_add_statuses/migration.sql deleted file mode 100644 index 8f859127..00000000 --- a/prisma/migrations/20230104055428_add_statuses/migration.sql +++ /dev/null @@ -1,5 +0,0 @@ --- CreateEnum -CREATE TYPE "Status" AS ENUM ('IN_REVIEW', 'REJECTED', 'WAITLISTED', 'ACCEPTED', 'RSVP', 'CHECKED_IN'); - --- AlterTable -ALTER TABLE "User" ADD COLUMN "status" "Status" NOT NULL DEFAULT 'IN_REVIEW'; diff --git a/prisma/migrations/20230109002233_add_qr_code_field/migration.sql b/prisma/migrations/20230109002233_add_qr_code_field/migration.sql deleted file mode 100644 index 78a32a57..00000000 --- a/prisma/migrations/20230109002233_add_qr_code_field/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[qrcode]` on the table `User` will be added. If there are existing duplicate values, this will fail. - -*/ --- AlterTable -ALTER TABLE "User" ADD COLUMN "qrcode" INTEGER; - --- CreateIndex -CREATE UNIQUE INDEX "User_qrcode_key" ON "User"("qrcode"); diff --git a/prisma/migrations/20230112043530_add_meal_counter/migration.sql b/prisma/migrations/20230112043530_add_meal_counter/migration.sql deleted file mode 100644 index 7acb6936..00000000 --- a/prisma/migrations/20230112043530_add_meal_counter/migration.sql +++ /dev/null @@ -1,3 +0,0 @@ --- AlterTable -ALTER TABLE "User" ADD COLUMN "lastMealTaken" TIMESTAMP(3), -ADD COLUMN "mealsTaken" INTEGER NOT NULL DEFAULT 0; diff --git a/prisma/migrations/20230112063406_add_food_manager_role/migration.sql b/prisma/migrations/20230112063406_add_food_manager_role/migration.sql deleted file mode 100644 index 7928e626..00000000 --- a/prisma/migrations/20230112063406_add_food_manager_role/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterEnum -ALTER TYPE "Role" ADD VALUE 'FOOD_MANAGER'; diff --git a/prisma/migrations/20230113051706_add_other_roles/migration.sql b/prisma/migrations/20230113051706_add_other_roles/migration.sql deleted file mode 100644 index 45187515..00000000 --- a/prisma/migrations/20230113051706_add_other_roles/migration.sql +++ /dev/null @@ -1,10 +0,0 @@ --- AlterEnum --- This migration adds more than one value to an enum. --- With PostgreSQL versions 11 and earlier, this is not possible --- in a single migration. This can be worked around by creating --- multiple migrations, each migration adding only one value to --- the enum. - - -ALTER TYPE "Role" ADD VALUE 'EVENT_MANAGER'; -ALTER TYPE "Role" ADD VALUE 'GENERAL_SCANNER'; diff --git a/prisma/migrations/20230113051945_add_event_log/migration.sql b/prisma/migrations/20230113051945_add_event_log/migration.sql deleted file mode 100644 index 641d4d39..00000000 --- a/prisma/migrations/20230113051945_add_event_log/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ --- CreateTable -CREATE TABLE "EventLog" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "event" TEXT NOT NULL, - - CONSTRAINT "EventLog_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "EventLog" ADD CONSTRAINT "EventLog_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230113052447_add_sponser_role/migration.sql b/prisma/migrations/20230113052447_add_sponser_role/migration.sql deleted file mode 100644 index b48edf3f..00000000 --- a/prisma/migrations/20230113052447_add_sponser_role/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterEnum -ALTER TYPE "Role" ADD VALUE 'SPONSER'; diff --git a/prisma/migrations/20230906034517_add_nextauth_expiry/migration.sql b/prisma/migrations/20230906034517_add_nextauth_expiry/migration.sql deleted file mode 100644 index 1c3acf40..00000000 --- a/prisma/migrations/20230906034517_add_nextauth_expiry/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "Account" ADD COLUMN "ext_expires_in" INTEGER; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml deleted file mode 100644 index fbffa92c..00000000 --- a/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "postgresql" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 00061c30..b77b5491 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,16 +1,9 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - generator client { provider = "prisma-client-js" } datasource db { - provider = "postgresql" - // NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.text annotations in model Account below - // Further reading: - // https://next-auth.js.org/adapters/prisma#create-the-prisma-schema - // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string + provider = "cockroachdb" url = env("DATABASE_URL") } @@ -21,16 +14,16 @@ model Account { type String provider String providerAccountId String - refresh_token String? @db.Text + refresh_token String? refresh_token_expires_in Int? - access_token String? @db.Text + access_token String? expires_at Int? ext_expires_in Int? - oauth_token_secret String? @db.Text - oauth_token String? @db.Text + oauth_token_secret String? + oauth_token String? token_type String? scope String? - id_token String? @db.Text + id_token String? session_state String? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@ -53,7 +46,7 @@ model User { image String? accounts Account[] sessions Session[] - typeform_response_id String? @db.Text + typeform_response_id String? role Role[] @default([HACKER]) hacker Review[] @relation("hacker") reviewer Review[] @relation("reviewer") @@ -67,10 +60,11 @@ model User { model Review { id String @id @default(cuid()) hackerId String - hacker User @relation("hacker", fields: [hackerId], references: [id], onDelete: Cascade) reviewerId String - reviewer User @relation("reviewer", fields: [reviewerId], references: [id], onDelete: Cascade) mark Float @default(0) + + hacker User @relation("hacker", fields: [hackerId], references: [id], onDelete: Cascade) + reviewer User @relation("reviewer", fields: [reviewerId], references: [id], onDelete: Cascade) } model EventLog { @@ -81,6 +75,14 @@ model EventLog { event String } +model VerificationToken { + identifier String + token String @unique + expires DateTime + + @@unique([identifier, token]) +} + enum Role { HACKER ADMIN @@ -99,11 +101,3 @@ enum Status { RSVP CHECKED_IN } - -model VerificationToken { - identifier String - token String @unique - expires DateTime - - @@unique([identifier, token]) -}