import pool from './db.js';
import bcrypt from 'bcrypt';
import { v4 as uuidv4 } from 'uuid';
async function seedAdmin() {
    try {
        const [rows] = await pool.query('SELECT * FROM users WHERE username = ?', ['admin']);
        if (rows.length > 0) {
            console.log('Admin user already exists.');
            process.exit(0);
        }
        const hashedPassword = await bcrypt.hash('admin123', 10);
        const id = uuidv4();
        await pool.query('INSERT INTO users (id, username, password_hash) VALUES (?, ?, ?)', [id, 'admin', hashedPassword]);
        console.log('Admin user created successfully: admin / admin123');
        process.exit(0);
    }
    catch (error) {
        console.error('Error seeding user:', error);
        process.exit(1);
    }
}
seedAdmin();
//# sourceMappingURL=seed_admin.js.map