<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Jalankan migrasi.
     */
    public function up(): void
    {
        Schema::create('akun_teknisis', function (Blueprint $table) {
            $table->id('id_akun_teknisi'); // Primary Key
            $table->unsignedBigInteger('id_teknisi')->unique(); // Foreign Key ke tabel teknisis
            $table->string('username')->unique();
            $table->string('password');
            $table->enum('status', ['aktif', 'tidak_aktif'])->default('aktif');
            $table->timestamps();

            // Definisi Foreign Key Constraint
            $table->foreign('id_teknisi')->references('id_teknisi')->on('teknisis')->onDelete('cascade');
        });
    }

    /**
     * Kembalikan migrasi.
     */
    public function down(): void
    {
        Schema::dropIfExists('akun_teknisis');
    }
};