const bcrypt = require('bcryptjs'); const { User } = require('../models'); module.exports = { up: async (queryInterface, Sequelize) => { try { // Create admin user const adminPassword = process.env.ADMIN_PASSWORD || 'admin123'; const saltRounds = 12; const passwordHash = await bcrypt.hash(adminPassword, saltRounds); const adminUser = await User.create({ email: 'admin@reasonflow.com', password_hash: passwordHash, first_name: 'Admin', last_name: 'User', role: 'admin', is_active: true, preferences: { theme: 'light', notifications: true, language: 'en' } }); console.log('✅ Admin user created:', adminUser.email); return adminUser; } catch (error) { console.error('❌ Error creating admin user:', error); throw error; } }, down: async (queryInterface, Sequelize) => { try { await User.destroy({ where: { email: 'admin@reasonflow.com' } }); console.log('✅ Admin user removed'); } catch (error) { console.error('❌ Error removing admin user:', error); throw error; } } };