<?php
require_once 'includes/config.php';

try {
    // Pilih database
    $db_auth->exec("USE " . DB_AUTH_NAME);
    
    // Hapus data lama di tabel superadmin
    $db_auth->exec("TRUNCATE TABLE superadmin");
    
    // Buat password baru
    $password = 'admin123';
    $hash = password_hash($password, PASSWORD_DEFAULT);
    
    // Insert data baru
    $stmt = $db_auth->prepare("
        INSERT INTO superadmin (username, password, nama_lengkap, email) 
        VALUES (?, ?, ?, ?)
    ");
    
    $stmt->execute([
        'superadmin',
        $hash,
        'Super Admin',
        'superadmin@miracle.tech'
    ]);
    
    // Cek data yang baru diinsert
    $result = $db_auth->query("SELECT id, username, password FROM superadmin");
    echo "<pre>";
    print_r($result->fetch(PDO::FETCH_ASSOC));
    echo "</pre>";
    
} catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
?> 