Skip to content

Commit

Permalink
add roles
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ivashchuk committed Mar 26, 2024
1 parent da83913 commit f6c6d42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions prisma/migrations/20240326210506_add_roles/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'SUPER_ADMIN');

-- AlterTable
ALTER TABLE "User" ADD COLUMN "role" "Role" NOT NULL DEFAULT 'USER';
6 changes: 6 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ datasource db {
url = env("DATABASE_URL")
}

enum Role {
USER
SUPER_ADMIN
}

// Necessary for Next auth
model Account {
id String @id @default(cuid())
Expand Down Expand Up @@ -47,6 +52,7 @@ model User {
email String? @unique
emailVerified DateTime?
image String?
role Role @default(USER)
accounts Account[]
sessions Session[]
}
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"**/*.js",
".next/types/**/*.ts",
"src/env.mjs",
"next.config.mjs"
"next.config.mjs",
"prettier.config.mjs",
"prettier.config.mjs"
],
"exclude": ["node_modules"]
}

0 comments on commit f6c6d42

Please sign in to comment.