const { PrismaClient, Role } = require("@prisma/client"); const prisma = new PrismaClient(); async function main() { const username = process.env.SUPER_ADMIN_USERNAME || "super"; const hash = process.env.SUPER_ADMIN_PASSWORD_HASH; if (!hash) { console.warn( "[seed] SUPER_ADMIN_PASSWORD_HASH env not set; skipping super-admin provisioning." ); console.warn( "[seed] Generate one with: node -e \"import('bcryptjs').then(b => b.default.hash('YOUR_PASSWORD', 12).then(console.log))\"" ); return; } await prisma.adminUser.upsert({ where: { username }, update: { passwordHash: hash, role: Role.SUPER_ADMIN, }, create: { username, passwordHash: hash, role: Role.SUPER_ADMIN, }, }); console.log(`[seed] Super-admin '${username}' provisioned.`); } main() .catch((e) => { console.error("[seed] failed:", e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });