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

const prisma = new PrismaClient();

async function main() {
  const passwordHash = await bcrypt.hash("kj123456", 10);

  await prisma.sysUser.upsert({
    where: { username: "admin_demo" },
    update: { passwordHash },
    create: {
      userId: "ADMIN_001",
      username: "admin_demo",
      passwordHash,
      role: "admin",
    },
  });

  console.log("Seed 完成：admin_demo / kj123456");
}

main()
  .catch((error) => {
    console.error("Seed 失败:", error);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
