import "dotenv/config"; import { prisma } from "../src/database/client"; import { hashPassword } from "../src/security/crypto"; async function seed() { const email = process.env.ADMIN_EMAIL ?? "admin@localhost"; const password = process.env.ADMIN_PASSWORD ?? "changeme123"; const existing = await prisma.user.findUnique({ where: { email } }); if (!existing) { await prisma.user.create({ data: { email, passwordHash: await hashPassword(password), name: "Admin", }, }); console.log(`Created admin: ${email}`); } const locations = ["Main", "Remote-01"]; for (const name of locations) { await prisma.location.upsert({ where: { name }, create: { name, priority: name === "Main" ? 10 : 0 }, update: {}, }); } console.log("Seed completed"); } seed() .catch(console.error) .finally(() => prisma.$disconnect());