// hDiyanetProxy - Seed Script // İlk admin kullanıcıyı oluşturur const pool = require('./db'); const bcrypt = require('bcrypt'); async function seed() { console.log('🌱 Seed başlatılıyor...\n'); try { // Admin kullanıcı kontrolü const [existing] = await pool.execute('SELECT id FROM users WHERE username = ?', ['admin']); if (existing.length > 0) { console.log(' ℹ️ Admin kullanıcı zaten mevcut, atlanıyor'); } else { const hashedPassword = await bcrypt.hash('admin123', 10); await pool.execute( 'INSERT INTO users (username, password, role, is_active) VALUES (?, ?, ?, ?)', ['admin', hashedPassword, 'admin', 1] ); console.log(' ✅ Admin kullanıcı oluşturuldu (admin / admin123)'); } } catch (err) { console.error(' ❌ Seed hatası:', err.message); } console.log('\n✅ Seed tamamlandı!'); process.exit(0); } seed();