import { PrismaClient as CentralPrismaClient } from '../node_modules/.prisma/central'; import * as bcrypt from 'bcrypt'; // Central database client const centralPrisma = new CentralPrismaClient(); async function createAdminUser() { const email = 'admin@example.com'; const password = 'admin123'; const firstName = 'Admin'; const lastName = 'User'; try { // Check if admin user already exists const existingUser = await centralPrisma.user.findUnique({ where: { email }, }); if (existingUser) { console.log(`User ${email} already exists`); return; } // Hash password const hashedPassword = await bcrypt.hash(password, 10); // Create admin user in central database const user = await centralPrisma.user.create({ data: { email, password: hashedPassword, firstName, lastName, role: 'superadmin', isActive: true, }, }); console.log('\nAdmin user created successfully!'); console.log('Email:', email); console.log('Password:', password); console.log('User ID:', user.id); } catch (error) { console.error('Error creating admin user:', error); } finally { await centralPrisma.$disconnect(); } } createAdminUser();