26 lines
662 B
JavaScript
26 lines
662 B
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const bcrypt = require('bcrypt');
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const existing = await prisma.user.findUnique({ where: { email: 'admin@wraith.local' } });
|
|
if (existing) {
|
|
console.log('Seed: admin user already exists, skipping');
|
|
return;
|
|
}
|
|
const hash = await bcrypt.hash('wraith', 10);
|
|
await prisma.user.create({
|
|
data: {
|
|
email: 'admin@wraith.local',
|
|
passwordHash: hash,
|
|
displayName: 'Admin',
|
|
},
|
|
});
|
|
console.log('Seed complete: admin@wraith.local / wraith');
|
|
}
|
|
|
|
main()
|
|
.catch(console.error)
|
|
.finally(() => prisma.$disconnect());
|