wraith/backend/seed.js
Vantz Stockwell 4ccf138744 fix: seed script checks for any existing user, not just admin@wraith.local
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>
2026-03-14 01:48:19 -04:00

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());