Skip to content

Commit

Permalink
usergroup migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Aug 13, 2023
1 parent 893630e commit d606db1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- CreateEnum
CREATE TYPE "AccessLevel" AS ENUM ('READ_ONLY', 'WRITE', 'ADMINISTRATIVE');

-- AlterTable
ALTER TABLE "User" ADD COLUMN "userGroupId" INTEGER;

Expand All @@ -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")
Expand All @@ -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;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d606db1

Please sign in to comment.