import { PrismaClient } from "@prisma/client";
import bcrypt from "bcryptjs";

const prisma = new PrismaClient();

async function main() {
  const pw = process.env.ADMIN_PASSWORD || "11210119";
  const hash = await bcrypt.hash(pw, 10);
  await prisma.setting.upsert({
    where: { key: "auth.passwordHash" },
    create: { key: "auth.passwordHash", value: hash },
    update: { value: hash },
  });
  console.log(`seeded auth.passwordHash (len=${hash.length})`);
}

main().finally(() => prisma.$disconnect());
