33 lines
653 B
TypeScript
33 lines
653 B
TypeScript
import { prisma } from '../src/lib/prisma';
|
|
import bcrypt from 'bcryptjs';
|
|
|
|
async function main() {
|
|
console.log('Seeding admin user...');
|
|
|
|
const email = 'admin@gmail.com';
|
|
const plainPassword = 'admin';
|
|
const hashedPassword = await bcrypt.hash(plainPassword, 10);
|
|
|
|
const admin = await prisma.user.upsert({
|
|
where: { email },
|
|
update: {
|
|
password: hashedPassword,
|
|
},
|
|
create: {
|
|
email,
|
|
password: hashedPassword,
|
|
},
|
|
});
|
|
|
|
console.log('Admin user seeded:', admin.email);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|