update seed to include user role

This commit is contained in:
Brandon Egger 2023-05-22 23:11:35 -05:00
parent 6bcd20897d
commit f63f141d72
2 changed files with 12 additions and 2 deletions

View File

@ -14,6 +14,10 @@ datasource db {
url = env("DATABASE_URL")
}
enum Role {
ADMIN
}
enum Platform {
APP_IOS
APP_ANDROID
@ -85,6 +89,7 @@ model User {
name String
username String @unique
password String
role Role
sessions Session[]
}

View File

@ -1,4 +1,4 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient, Role } from "@prisma/client";
import * as argon2 from "argon2";
import * as dotenv from "dotenv";
@ -16,11 +16,16 @@ async function main() {
await prisma.user.upsert({
where: { username: "admin" },
update: {},
update: {
name: "Admin User",
password: hashedPassword,
role: Role.ADMIN,
},
create: {
name: "Admin User",
username: "admin",
password: hashedPassword,
role: Role.ADMIN,
},
});
}