From d606db1e7468916c4d28fd23d7298fe25f68257f Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Sun, 13 Aug 2023 19:59:41 +0000 Subject: [PATCH] usergroup migration --- .../migration.sql | 6 +++++- prisma/schema.prisma | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) rename prisma/migrations/{20230812171940_user_group => 20230813195808_user_group}/migration.sql (67%) diff --git a/prisma/migrations/20230812171940_user_group/migration.sql b/prisma/migrations/20230813195808_user_group/migration.sql similarity index 67% rename from prisma/migrations/20230812171940_user_group/migration.sql rename to prisma/migrations/20230813195808_user_group/migration.sql index e697374e..2edba1f3 100644 --- a/prisma/migrations/20230812171940_user_group/migration.sql +++ b/prisma/migrations/20230813195808_user_group/migration.sql @@ -1,3 +1,6 @@ +-- CreateEnum +CREATE TYPE "AccessLevel" AS ENUM ('READ_ONLY', 'WRITE', 'ADMINISTRATIVE'); + -- AlterTable ALTER TABLE "User" ADD COLUMN "userGroupId" INTEGER; @@ -7,6 +10,7 @@ CREATE TABLE "UserGroup" ( "name" TEXT NOT NULL, "description" TEXT, "maxNetworks" INTEGER NOT NULL DEFAULT 5, + "accessLevel" "AccessLevel" NOT NULL DEFAULT 'WRITE', "isDefault" BOOLEAN NOT NULL DEFAULT false, CONSTRAINT "UserGroup_pkey" PRIMARY KEY ("id") @@ -16,4 +20,4 @@ CREATE TABLE "UserGroup" ( CREATE UNIQUE INDEX "UserGroup_name_key" ON "UserGroup"("name"); -- AddForeignKey -ALTER TABLE "User" ADD CONSTRAINT "User_userGroupId_fkey" FOREIGN KEY ("userGroupId") REFERENCES "UserGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "User" ADD CONSTRAINT "User_userGroupId_fkey" FOREIGN KEY ("userGroupId") REFERENCES "UserGroup"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 25c30ceb..99f5a764 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -197,7 +197,7 @@ model VerificationToken { } // To map your data model to the database schema, you need to use the prisma migrate CLI commands: -// npx prisma migrate dev --name init +// npx prisma migrate dev --name (NAME) // reset db // npx prisma migrate reset