import User from './models/User.js';

/** Create demo admin when the database has no users (local dev). */
export async function ensureDefaultAdmin() {
  const count = await User.countDocuments();
  if (count > 0) return;

  await User.create({
    name: 'Admin User',
    email: 'admin@school.edu',
    password: 'admin123',
    role: 'admin',
  });
  console.log('Default admin created: admin@school.edu / admin123');
  console.log('Run "npm run seed" from the project root for full demo data.');
}
