Previously the seed only checked for admin@wraith.local by email, so it would create a duplicate if the admin had changed their email. Now skips seeding entirely if any user exists. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
615 B
JavaScript
26 lines
615 B
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const bcrypt = require('bcrypt');
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const userCount = await prisma.user.count();
|
|
if (userCount > 0) {
|
|
console.log('Seed: users already exist, 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());
|