diff --git a/.eslintrc.json b/.eslintrc.json index 86999d9..1e5e448 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,12 +1,6 @@ { - "extends": [ - "next", - "next/core-web-vitals", - "plugin:prettier/recommended" - ], - "plugins": [ - "prettier" - ], + "extends": ["next", "next/core-web-vitals", "plugin:prettier/recommended"], + "plugins": ["prettier"], "rules": { "prettier/prettier": [ "error", @@ -16,4 +10,4 @@ ], "no-unused-vars": "error" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 808528c..7ef9436 100644 --- a/package.json +++ b/package.json @@ -70,4 +70,4 @@ "npx prisma format" ] } -} \ No newline at end of file +} diff --git a/prisma/migrations/20240928220618_init/migration.sql b/prisma/migrations/20240928220618_init/migration.sql new file mode 100644 index 0000000..7f8ab45 --- /dev/null +++ b/prisma/migrations/20240928220618_init/migration.sql @@ -0,0 +1,34 @@ +/* + Warnings: + + - You are about to drop the column `numberOfStudents` on the `Absence` table. All the data in the column will be lost. + - You are about to drop the column `subject` on the `Absence` table. All the data in the column will be lost. + - A unique constraint covering the columns `[authId]` on the table `User` will be added. If there are existing duplicate values, this will fail. + - Added the required column `subjectId` to the `Absence` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Absence" DROP COLUMN "numberOfStudents", +DROP COLUMN "subject", +ADD COLUMN "subjectId" INTEGER NOT NULL; + +-- AlterTable +ALTER TABLE "User" ADD COLUMN "numOfAbsences" INTEGER NOT NULL DEFAULT 10; + +-- DropEnum +DROP TYPE "Subject"; + +-- CreateTable +CREATE TABLE "Subject" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + "abbreviation" TEXT NOT NULL, + + CONSTRAINT "Subject_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_authId_key" ON "User"("authId"); + +-- AddForeignKey +ALTER TABLE "Absence" ADD CONSTRAINT "Absence_subjectId_fkey" FOREIGN KEY ("subjectId") REFERENCES "Subject"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8a24d98..5981628 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -39,7 +39,7 @@ model Location { id Int @id @default(autoincrement()) name String abbreviation String - absences Absence[] + Absence Absence[] } model MailingList { @@ -52,7 +52,7 @@ model Subject { id Int @id @default(autoincrement()) name String abbreviation String - absences Absence[] + Absence Absence[] } enum Role { diff --git a/prisma/seed/.snaplet/dataModel.json b/prisma/seed/.snaplet/dataModel.json index b5db21d..e68835f 100644 --- a/prisma/seed/.snaplet/dataModel.json +++ b/prisma/seed/.snaplet/dataModel.json @@ -127,12 +127,8 @@ "isRequired": true, "kind": "object", "relationName": "AbsenceToLocation", - "relationFromFields": [ - "locationId" - ], - "relationToFields": [ - "id" - ], + "relationFromFields": ["locationId"], + "relationToFields": ["id"], "isList": false, "isId": false, "isGenerated": false, @@ -145,12 +141,8 @@ "isRequired": true, "kind": "object", "relationName": "AbsenceToSubject", - "relationFromFields": [ - "subjectId" - ], - "relationToFields": [ - "id" - ], + "relationFromFields": ["subjectId"], + "relationToFields": ["id"], "isList": false, "isId": false, "isGenerated": false, @@ -163,12 +155,8 @@ "isRequired": true, "kind": "object", "relationName": "Absence_absentTeacherIdToUser", - "relationFromFields": [ - "absentTeacherId" - ], - "relationToFields": [ - "id" - ], + "relationFromFields": ["absentTeacherId"], + "relationToFields": ["id"], "isList": false, "isId": false, "isGenerated": false, @@ -181,12 +169,8 @@ "isRequired": false, "kind": "object", "relationName": "Absence_substituteTeacherIdToUser", - "relationFromFields": [ - "substituteTeacherId" - ], - "relationToFields": [ - "id" - ], + "relationFromFields": ["substituteTeacherId"], + "relationToFields": ["id"], "isList": false, "isId": false, "isGenerated": false, @@ -197,9 +181,7 @@ "uniqueConstraints": [ { "name": "Absence_pkey", - "fields": [ - "id" - ], + "fields": ["id"], "nullNotDistinct": false } ] @@ -273,9 +255,7 @@ "uniqueConstraints": [ { "name": "Location_pkey", - "fields": [ - "id" - ], + "fields": ["id"], "nullNotDistinct": false } ] @@ -335,9 +315,7 @@ "uniqueConstraints": [ { "name": "MailingList_pkey", - "fields": [ - "id" - ], + "fields": ["id"], "nullNotDistinct": false } ] @@ -411,9 +389,7 @@ "uniqueConstraints": [ { "name": "Subject_pkey", - "fields": [ - "id" - ], + "fields": ["id"], "nullNotDistinct": false } ] @@ -571,23 +547,17 @@ "uniqueConstraints": [ { "name": "User_pkey", - "fields": [ - "id" - ], + "fields": ["id"], "nullNotDistinct": false }, { "name": "User_authId_key", - "fields": [ - "authId" - ], + "fields": ["authId"], "nullNotDistinct": false }, { "name": "User_email_key", - "fields": [ - "email" - ], + "fields": ["email"], "nullNotDistinct": false } ] @@ -620,4 +590,4 @@ ] } } -} \ No newline at end of file +}