28 lines
733 B
JavaScript
28 lines
733 B
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
const prisma = new PrismaClient({});
|
|
|
|
async function main() {
|
|
const adminEmail = 'admin@tesscorp.com.mx';
|
|
const existingAdmin = await prisma.user.findUnique({ where: { email: adminEmail } });
|
|
|
|
if (!existingAdmin) {
|
|
const hashedPassword = await bcrypt.hash('SoporteTess2026!', 10);
|
|
await prisma.user.create({
|
|
data: {
|
|
email: adminEmail,
|
|
password: hashedPassword,
|
|
role: 'ADMIN'
|
|
}
|
|
});
|
|
console.log('Admin user created successfully');
|
|
} else {
|
|
console.log('Admin user already exists');
|
|
}
|
|
}
|
|
|
|
main()
|
|
.catch(e => console.error(e))
|
|
.finally(async () => await prisma.$disconnect());
|