<?php
$mysqli = new mysqli("127.0.0.1", "root", "", "siakad");

$res = $mysqli->query("SHOW TABLES LIKE 'penugasan_dosen'");
if ($res->num_rows == 0) {
    $sql = "CREATE TABLE `penugasan_dosen` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `id_registrasi_dosen` varchar(36) DEFAULT NULL,
      `id_dosen` int(11) unsigned NOT NULL,
      `id_program_studi` int(11) unsigned DEFAULT NULL,
      `id_tahun_ajaran` varchar(10) DEFAULT NULL,
      `nama_tahun_ajaran` varchar(50) DEFAULT NULL,
      `nama_program_studi` varchar(100) DEFAULT NULL,
      `no_surat_tugas` varchar(100) DEFAULT NULL,
      `tanggal_surat_tugas` date DEFAULT NULL,
      `is_homebase` enum('Ya','Tidak') DEFAULT 'Tidak',
      `created_at` datetime DEFAULT NULL,
      `updated_at` datetime DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
    
    if($mysqli->query($sql)) {
        echo "Table penugasan_dosen created successfully.";
    } else {
        echo "Error: " . $mysqli->error;
    }
} else {
    echo "Table penugasan_dosen already exists.";
}
?>
