const { PrismaClient } = require('@prisma/client');
const bcrypt = require('bcryptjs');

const prisma = new PrismaClient();

async function main() {
  const plainPassword = process.env.ADMIN_PASSWORD || 'admin';
  const hashed = await bcrypt.hash(plainPassword, 10);

  await prisma.admin.upsert({
    where: { id: 1 },
    update: {},
    create: { id: 1, password: hashed }
  });

  console.log('✅ Admin erstellt oder aktualisiert');
}

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