From 8c40c1cae5ac2b7d1ee5418bed5903062fa91cf9 Mon Sep 17 00:00:00 2001 From: Kevin Ge Date: Fri, 21 Jul 2023 21:15:28 -0700 Subject: [PATCH 1/2] fix: initialize migrations --- .../20230722041429_init/migration.sql | 228 ++++++++++++++++++ prisma/migrations/migration_lock.toml | 3 + 2 files changed, 231 insertions(+) create mode 100644 prisma/migrations/20230722041429_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml diff --git a/prisma/migrations/20230722041429_init/migration.sql b/prisma/migrations/20230722041429_init/migration.sql new file mode 100644 index 000000000..d0c33fb7b --- /dev/null +++ b/prisma/migrations/20230722041429_init/migration.sql @@ -0,0 +1,228 @@ +-- CreateEnum +CREATE TYPE "SemesterType" AS ENUM ('f', 's', 'u'); + +-- CreateEnum +CREATE TYPE "TemplateDataType" AS ENUM ('CORE', 'OPTIONAL'); + +-- CreateTable +CREATE TABLE "TemplateData" ( + "id" UUID NOT NULL, + "semester" INTEGER NOT NULL, + "templateId" UUID NOT NULL, + + CONSTRAINT "TemplateData_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TemplateItem" ( + "id" UUID NOT NULL, + "name" TEXT NOT NULL, + "type" "TemplateDataType" NOT NULL DEFAULT 'CORE', + "templateDataId" UUID NOT NULL, + + CONSTRAINT "TemplateItem_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Template" ( + "id" UUID NOT NULL, + "name" TEXT, + + CONSTRAINT "Template_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Profile" ( + "id" UUID NOT NULL, + "name" TEXT NOT NULL, + "startYear" INTEGER NOT NULL, + "startSemester" "SemesterType" NOT NULL, + "endYear" INTEGER NOT NULL, + "endSemester" "SemesterType" NOT NULL, + "userId" UUID NOT NULL, + + CONSTRAINT "Profile_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Plan" ( + "id" UUID NOT NULL, + "name" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "transferCredits" TEXT[], + "userId" UUID NOT NULL, + "startYear" INTEGER NOT NULL, + "startSemester" "SemesterType" NOT NULL, + "endYear" INTEGER NOT NULL, + "endSemester" "SemesterType" NOT NULL, + + CONSTRAINT "Plan_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "DegreeRequirements" ( + "id" UUID NOT NULL, + "major" TEXT NOT NULL, + "bypasses" TEXT[], + "planId" UUID NOT NULL, + + CONSTRAINT "DegreeRequirements_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Bypass" ( + "id" UUID NOT NULL, + "courseCode" TEXT NOT NULL, + "requirement" TEXT NOT NULL, + "hours" INTEGER NOT NULL, + + CONSTRAINT "Bypass_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Course" ( + "id" UUID NOT NULL, + "code" TEXT NOT NULL, + "color" TEXT NOT NULL DEFAULT '', + "semesterId" UUID NOT NULL, + "locked" BOOLEAN NOT NULL DEFAULT false, + "prereqOverriden" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Course_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Semester" ( + "id" UUID NOT NULL, + "year" INTEGER NOT NULL, + "semester" "SemesterType" NOT NULL, + "planId" UUID NOT NULL, + "color" TEXT NOT NULL DEFAULT '', + "locked" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Semester_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Credit" ( + "id" UUID NOT NULL, + "courseCode" TEXT NOT NULL, + "year" INTEGER NOT NULL, + "semester" "SemesterType" NOT NULL, + "transfer" BOOLEAN NOT NULL, + "userId" UUID NOT NULL, + + CONSTRAINT "Credit_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AcademicDetails" ( + "id" SERIAL NOT NULL, + + CONSTRAINT "AcademicDetails_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Account" ( + "id" UUID NOT NULL, + "type" TEXT NOT NULL, + "provider" TEXT NOT NULL, + "providerAccountId" TEXT NOT NULL, + "refresh_token" TEXT, + "access_token" TEXT, + "expires_at" INTEGER, + "token_type" TEXT, + "scope" TEXT, + "id_token" TEXT, + "session_state" TEXT, + "userId" UUID NOT NULL, + + CONSTRAINT "Account_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Session" ( + "id" UUID NOT NULL, + "sessionToken" TEXT NOT NULL, + "expires" TIMESTAMP(3) NOT NULL, + "userId" UUID NOT NULL, + + CONSTRAINT "Session_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "User" ( + "id" UUID NOT NULL, + "email" TEXT, + "emailVerified" TIMESTAMP(3), + "onboardingComplete" BOOLEAN NOT NULL DEFAULT false, + "seenHomeOnboardingModal" BOOLEAN NOT NULL DEFAULT false, + "seenPlanOnboardingModal" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "VerificationToken" ( + "id" SERIAL NOT NULL, + "identifier" TEXT NOT NULL, + "token" TEXT NOT NULL, + "expires" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "VerificationToken_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "DegreeRequirements_planId_key" ON "DegreeRequirements"("planId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Course_semesterId_code_key" ON "Course"("semesterId", "code"); + +-- 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 "TemplateData" ADD CONSTRAINT "TemplateData_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "TemplateItem" ADD CONSTRAINT "TemplateItem_templateDataId_fkey" FOREIGN KEY ("templateDataId") REFERENCES "TemplateData"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Plan" ADD CONSTRAINT "Plan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "DegreeRequirements" ADD CONSTRAINT "DegreeRequirements_planId_fkey" FOREIGN KEY ("planId") REFERENCES "Plan"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Course" ADD CONSTRAINT "Course_semesterId_fkey" FOREIGN KEY ("semesterId") REFERENCES "Semester"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Semester" ADD CONSTRAINT "Semester_planId_fkey" FOREIGN KEY ("planId") REFERENCES "Plan"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Credit" ADD CONSTRAINT "Credit_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- 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/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 000000000..fbffa92c2 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# 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 From 7e23edb4ce6cc0303bcadb589a254ee557708ff7 Mon Sep 17 00:00:00 2001 From: Kevin Ge Date: Fri, 21 Jul 2023 21:34:11 -0700 Subject: [PATCH 2/2] fix: add migration to build script and workflows --- .github/workflows/tests.yml | 2 +- package-lock.json | 180 ++++++++++++++++++ package.json | 4 +- .../migration.sql | 0 4 files changed, 183 insertions(+), 3 deletions(-) rename prisma/migrations/{20230722041429_init => 20230722042705_0_init}/migration.sql (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5783f60f7..ac8e9ef10 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,7 +56,7 @@ jobs: - name: Prisma generate and push run: | npm run prisma:generate && - npx prisma db push + npm run prisma:migrate:deploy - name: Run Cypress e2e tests run: | diff --git a/package-lock.json b/package-lock.json index 5434c6359..dcf016ef2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16085,6 +16085,186 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } + }, + "node_modules/@next/swc-android-arm-eabi": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.6.tgz", + "integrity": "sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-android-arm64": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.1.6.tgz", + "integrity": "sha512-cMwQjnB8vrYkWyK/H0Rf2c2pKIH4RGjpKUDvbjVAit6SbwPDpmaijLio0LWFV3/tOnY6kvzbL62lndVA0mkYpw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.6.tgz", + "integrity": "sha512-/uOky5PaZDoaU99ohjtNcDTJ6ks/gZ5ykTQDvNZDjIoCxFe3+t06bxsTPY6tAO6uEAw5f6vVFX5H5KLwhrkZCA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-freebsd-x64": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.6.tgz", + "integrity": "sha512-qaEALZeV7to6weSXk3Br80wtFQ7cFTpos/q+m9XVRFggu+8Ib895XhMWdJBzew6aaOcMvYR6KQ6JmHA2/eMzWw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm-gnueabihf": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.6.tgz", + "integrity": "sha512-OybkbC58A1wJ+JrJSOjGDvZzrVEQA4sprJejGqMwiZyLqhr9Eo8FXF0y6HL+m1CPCpPhXEHz/2xKoYsl16kNqw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.6.tgz", + "integrity": "sha512-yCH+yDr7/4FDuWv6+GiYrPI9kcTAO3y48UmaIbrKy8ZJpi7RehJe3vIBRUmLrLaNDH3rY1rwoHi471NvR5J5NQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.6.tgz", + "integrity": "sha512-ECagB8LGX25P9Mrmlc7Q/TQBb9rGScxHbv/kLqqIWs2fIXy6Y/EiBBiM72NTwuXUFCNrWR4sjUPSooVBJJ3ESQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.6.tgz", + "integrity": "sha512-GT5w2mruk90V/I5g6ScuueE7fqj/d8Bui2qxdw6lFxmuTgMeol5rnzAv4uAoVQgClOUO/MULilzlODg9Ib3Y4Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.6.tgz", + "integrity": "sha512-keFD6KvwOPzmat4TCnlnuxJCQepPN+8j3Nw876FtULxo8005Y9Ghcl7ACcR8GoiKoddAq8gxNBrpjoxjQRHeAQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.6.tgz", + "integrity": "sha512-OwertslIiGQluFvHyRDzBCIB07qJjqabAmINlXUYt7/sY7Q7QPE8xVi5beBxX/rxTGPIbtyIe3faBE6Z2KywhQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.6.tgz", + "integrity": "sha512-g8zowiuP8FxUR9zslPmlju7qYbs2XBtTLVSxVikPtUDQedhcls39uKYLvOOd1JZg0ehyhopobRoH1q+MHlIN/w==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "13.1.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.6.tgz", + "integrity": "sha512-Ls2OL9hi3YlJKGNdKv8k3X/lLgc3VmLG3a/DeTkAd+lAituJp8ZHmRmm9f9SL84fT3CotlzcgbdaCDfFwFA6bA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/package.json b/package.json index 71d739acc..36827dbbb 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "scripts": { "dev": "next dev", "prisma:generate": "prisma generate --schema prisma/platform.prisma && prisma generate --schema prisma/schema.prisma", - "prisma:push:main": "prisma db push --schema prisma/schema.prisma", - "build": "npm run prisma:generate && npm run prisma:push:main && prisma db seed && next build", + "prisma:migrate:deploy": "prisma migrate deploy --schema prisma/schema.prisma", + "build": "npm run prisma:generate && next build && npm run prisma:migrate:deploy && prisma db seed", "start": "next start", "lint": "eslint --fix .", "format": "prettier --write .", diff --git a/prisma/migrations/20230722041429_init/migration.sql b/prisma/migrations/20230722042705_0_init/migration.sql similarity index 100% rename from prisma/migrations/20230722041429_init/migration.sql rename to prisma/migrations/20230722042705_0_init/migration.sql