35 lines
967 B
JavaScript
35 lines
967 B
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
(async () => {
|
|
const prisma = new PrismaClient();
|
|
try {
|
|
const email = 'admin@gymflow.com';
|
|
const password = 'admin123';
|
|
const hashedPassword = await bcrypt.hash(password, 10);
|
|
|
|
const user = await prisma.user.upsert({
|
|
where: { email },
|
|
update: {},
|
|
create: {
|
|
email,
|
|
password: hashedPassword,
|
|
role: 'ADMIN',
|
|
isFirstLogin: false,
|
|
profile: {
|
|
create: {
|
|
weight: 80,
|
|
height: 180,
|
|
gender: 'MALE'
|
|
}
|
|
}
|
|
}
|
|
});
|
|
console.log('Admin user created/verified:', user);
|
|
} catch (e) {
|
|
console.error('Error:', e);
|
|
} finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
})();
|