import { PrismaClient } from "@/generated/prisma/client"
import { getPasswordHash } from "@/lib/security"

const prisma = new PrismaClient()

async function main() {
  const user = await prisma.user.upsert({
    where: {
      email: "admin@localhost",
    },
    update: {},
    create: {
      name: "Administrator",
      username: "admin",
      email: "admin@localhost",
      role: "ADMIN",
      password: await getPasswordHash("admin"),
      isActive: true,
    },
  })
  console.log(user)
}

main()
  .then(async () => {
    await prisma.$disconnect()
  })
  .catch(async (e) => {
    console.error(e)
    await prisma.$disconnect()
    process.exit(1)
  })
