Files
myApp/prisma/seed.ts
T
2026-06-14 10:03:34 +07:00

35 lines
819 B
TypeScript

import { PrismaClient, Role, Status } from "@prisma/client";
import { hashPassword } from "../src/lib/password";
const prisma = new PrismaClient();
async function main() {
await prisma.user.upsert({
where: { email: "admin@4tech.co.th" },
update: {
fullName: "4TECH Super Admin",
role: Role.SUPER_ADMIN,
status: Status.ACTIVE
},
create: {
email: "admin@4tech.co.th",
passwordHash: await hashPassword("Admin@123456"),
fullName: "4TECH Super Admin",
department: "IT",
position: "System Administrator",
role: Role.SUPER_ADMIN,
status: Status.ACTIVE
}
});
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (error) => {
console.error(error);
await prisma.$disconnect();
process.exit(1);
});