<?php
$mysqli = new mysqli("127.0.0.1", "root", "", "siakad");
if ($mysqli->connect_error) die("Connect Error");

$sql = "CREATE TABLE IF NOT EXISTS `peserta_kelas` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `id_kelas_kuliah_pddikti` varchar(36) DEFAULT NULL,
  `id_mahasiswa_pddikti` varchar(36) DEFAULT NULL,
  `nim` varchar(50) DEFAULT NULL,
  `nama_mahasiswa` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";

if ($mysqli->query($sql)) {
    echo "Table peserta_kelas created successfully";
    
    // update migrations table manually to avoid spark migrate issue
    $mysqli->query("INSERT INTO migrations (version, class, `group`, namespace, time, batch) VALUES ('2026-06-24-092711', 'App\\\Database\\\Migrations\\\CreatePesertaKelasTable', 'default', 'App', UNIX_TIMESTAMP(), 3)");
} else {
    echo "Error: " . $mysqli->error;
}
