51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { PrismaClient, RoleType } from '@prisma/client';
|
|
import * as argon2 from 'argon2';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('🌱 Creating Custom Super Admin User...');
|
|
|
|
const passwordHash = await argon2.hash('Password123!');
|
|
const user = await prisma.user.upsert({
|
|
where: { email: 'emperor@luxe.com' },
|
|
update: {
|
|
role: RoleType.SUPER_ADMIN,
|
|
},
|
|
create: {
|
|
email: 'emperor@luxe.com',
|
|
username: 'luxe_emperor',
|
|
passwordHash: passwordHash,
|
|
role: RoleType.SUPER_ADMIN,
|
|
status: 'ACTIVE',
|
|
emailVerifiedAt: new Date(),
|
|
},
|
|
});
|
|
|
|
// Create Wallet for Custom Super Admin
|
|
await prisma.wallet.upsert({
|
|
where: { userId: user.id },
|
|
update: {},
|
|
create: {
|
|
userId: user.id,
|
|
balance: 500000.0,
|
|
credits: 20000.0,
|
|
currency: 'USD',
|
|
},
|
|
});
|
|
|
|
console.log('✅ Custom Super Admin created successfully!');
|
|
console.log('📧 Email: emperor@luxe.com');
|
|
console.log('👤 Username: luxe_emperor');
|
|
console.log('🔑 Password: Password123!');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('❌ Creation failed:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|