<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('pegawai_jabatan_histories', function (Blueprint $table) {
            $table->id();
            $table->foreignId('pegawai_id')->constrained('pegawai')->cascadeOnDelete();
            $table->foreignId('jabatan_fungsional_id')->nullable()->constrained('jabatan_fungsional')->nullOnDelete();
            $table->string('nama_jabatan')->nullable();
            $table->string('jenjang')->nullable();
            $table->string('golongan')->nullable();
            $table->date('tanggal_mulai_jabatan')->nullable();
            $table->foreignId('sk_file_id')->nullable()->constrained('pegawai_files')->nullOnDelete();
            $table->foreignId('admin_id')->nullable()->constrained('users')->nullOnDelete();
            $table->text('catatan')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('pegawai_jabatan_histories');
    }
};
