const { PrismaClient } = require('@prisma/client'); const crypto = require('crypto'); const prisma = new PrismaClient(); async function main() { try { // Use built-in crypto for quick hash (we'll update with proper one after) const salt = crypto.randomBytes(16).toString('hex'); const hash = crypto.pbkdf2Sync('admin', salt, 10000, 64, 'sha256').toString('hex'); const fullHash = `${salt}:${hash}`; // Generate cuid-like ID const cuid = `clx_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`; // Check if user exists const existing = await prisma.user.findUnique({ where: { email: 'david@dhg.lol' } }); if (existing) { await prisma.user.delete({ where: { id: existing.id } }); } // Create admin user const user = await prisma.user.create({ data: { id: cuid, email: 'david@dhg.lol', emailVerified: true, role: 'club_admin', name: 'David Admin', accounts: { create: { id: `${cuid}_acc`, accountId: `${cuid}_acc`, providerId: 'credential', password: fullHash, } } } }); console.log('✅ Admin user created successfully!'); console.log(' Email:', user.email); console.log(' Role:', user.role); console.log(' Password: admin'); } catch (error) { console.error('❌ Error:', error.message); } finally { await prisma.$disconnect(); } } main();