import { getPayload } from 'payload'; import configPromise from '../payload.config'; async function seed() { console.log('🌱 Starting PayloadCMS seed process...'); try { const payload = await getPayload({ config: configPromise }); // Check if any users exist const { totalDocs } = await payload.find({ collection: 'users', limit: 1, }); if (totalDocs === 0) { console.log('👤 No users found. Creating default admin user...'); await payload.create({ collection: 'users', data: { email: 'admin@mintel.me', password: 'klz-admin-setup', firstName: 'KLZ', lastName: 'Admin', role: 'admin', }, }); console.log('✅ Default admin user created successfully.'); } else { console.log(`â„šī¸ Database already contains ${totalDocs} users. Skipping user creation.`); } console.log('✅ PayloadCMS seed completed successfully!'); process.exit(0); } catch (error) { console.error('❌ Failed to seed PayloadCMS database:', error); process.exit(1); } } seed();