| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { PrismaClient } from '@prisma/client';
- import bcrypt from 'bcryptjs';
- const prisma = new PrismaClient();
- async function main() {
- console.log('🌱 Iniciando seeding de usuarios administrativos...');
- // Admin principal
- const adminPassword = await bcrypt.hash('admin123', 12);
- const adminIdentificacion = '0000000001';
- const admin = await prisma.user.upsert({
- where: { identificacion: adminIdentificacion },
- update: {},
- create: {
- email: 'amesas@utb.edu.ec',
- username: `${adminIdentificacion}-ADM`,
- identificacion: adminIdentificacion,
- name: 'Armando',
- lastname: 'Mesas',
- password: adminPassword,
- role: 'ADMIN',
- isExternalAuth: false,
- },
- });
- console.log('✅ Admin creado:', admin.username);
- // Doctor ejemplo
- const doctorPassword = await bcrypt.hash('doctor123', 12);
- const doctorIdentificacion = '0000000002';
- const doctor = await prisma.user.upsert({
- where: { identificacion: doctorIdentificacion },
- update: {},
- create: {
- email: 'shoria@utb.edu.ec',
- username: `${doctorIdentificacion}-DOC`,
- identificacion: doctorIdentificacion,
- name: 'Susana',
- lastname: 'Horia',
- password: doctorPassword,
- role: 'DOCTOR',
- isExternalAuth: false,
- },
- });
- console.log('✅ Doctor creado:', doctor.username);
- console.log('\n📋 Credenciales creadas:');
- console.log('----------------------------');
- console.log('Admin: 0000000001-ADM / admin123');
- console.log('Doctor: 0000000002-DOC / doctor123');
- console.log('----------------------------\n');
- }
- main()
- .then(async () => {
- await prisma.$disconnect();
- })
- .catch(async (e) => {
- console.error(e);
- await prisma.$disconnect();
- process.exit(1);
- });
|