43 lines
2.3 KiB
TypeScript
43 lines
2.3 KiB
TypeScript
import 'dotenv/config';
|
|
import bcrypt from 'bcryptjs';
|
|
import db from '../src/database/models/index.js';
|
|
import { ROLES } from '../src/common/config/constants.js';
|
|
|
|
const { User } = db;
|
|
|
|
async function seedUsers() {
|
|
console.log('🌱 Seeding users...');
|
|
try {
|
|
await db.sequelize.authenticate();
|
|
|
|
const hashedPassword = await bcrypt.hash('Admin@123', 10);
|
|
|
|
const usersToSeed = [
|
|
{ email: 'admin@royalenfield.com', fullName: 'Super Admin', password: hashedPassword, roleCode: ROLES.SUPER_ADMIN, status: 'active' },
|
|
{ email: 'piyush@royalenfield.com', fullName: 'piyush', password: hashedPassword, roleCode: ROLES.DD_ZM, status: 'active' },
|
|
{ email: 'manish@royalenfield.com', fullName: 'manish', password: hashedPassword, roleCode: ROLES.RBM, status: 'active' },
|
|
{ email: 'manav@royalenfield.com', fullName: 'manav', password: hashedPassword, roleCode: ROLES.ZBH, status: 'active' },
|
|
{ email: 'jaya@royalenfield.com', fullName: 'Jaya', password: hashedPassword, roleCode: ROLES.DD_LEAD, status: 'active' },
|
|
{ email: 'ganesh@royalenfield.com', fullName: 'ganesh', password: hashedPassword, roleCode: ROLES.DD_HEAD, status: 'active' },
|
|
{ email: 'yashwin@royalenfield.com', fullName: 'Yashwin', password: hashedPassword, roleCode: ROLES.NBH, status: 'active' },
|
|
{ email: 'fdd@royalenfield.com', fullName: 'FDD Team', password: hashedPassword, roleCode: ROLES.FDD, status: 'active' },
|
|
{ email: 'finance@royalenfield.com', fullName: 'Finance Admin', password: hashedPassword, roleCode: ROLES.FINANCE, status: 'active' },
|
|
{ email: 'abhishek@royalenfield.com', fullName: 'abhishek', password: hashedPassword, roleCode: ROLES.ASM, status: 'active' },
|
|
{ email: 'lince@royalenfield.com', fullName: 'Lince', password: hashedPassword, roleCode: ROLES.DD_ADMIN, status: 'active' },
|
|
{ email: 'legal@royalenfield.com', fullName: 'Legal Admin', password: hashedPassword, roleCode: ROLES.LEGAL_ADMIN, status: 'active' }
|
|
];
|
|
|
|
for (const u of usersToSeed) {
|
|
await User.upsert(u);
|
|
}
|
|
|
|
console.log('✅ Users seeded successfully!');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Seeding failed:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
seedUsers();
|