| import { PrismaClient } from '@prisma/client' | |
| const prisma = new PrismaClient() | |
| async function main() { | |
| const email = 'admin@example.com' | |
| const password = 'password123' | |
| const existingUser = await prisma.user.findUnique({ | |
| where: { email }, | |
| }) | |
| if (!existingUser) { | |
| console.log(`Creating user: ${email}`) | |
| await prisma.user.create({ | |
| data: { | |
| email, | |
| password, | |
| name: 'Admin User', | |
| role: 'SUPER_ADMIN', | |
| }, | |
| }) | |
| console.log('User created.') | |
| } else { | |
| console.log('User already exists.') | |
| } | |
| } | |
| main() | |
| .then(async () => { | |
| await prisma.$disconnect() | |
| }) | |
| .catch(async (e) => { | |
| console.error(e) | |
| await prisma.$disconnect() | |
| process.exit(1) | |
| }) | |