<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('Hukum', function (Blueprint $table) {
            $table->id('HukumId');
            $table->unsignedInteger('PerusahaanId')->nullable()->comment('id dari Perusahaan');
            $table->foreign('PerusahaanId')->references('PerusahaanId')->on('Perusahaan')->onDelete('cascade');
            $table->unsignedInteger('JenisSanksiId')->nullable()->comment('id dari Jenis Sanksi');
            $table->foreign('JenisSanksiId')->references('JenisSanksiId')->on('JenisSanksi')->onDelete('cascade');
            $table->string('SanksiNumber', 100)->nullable()->comment('nomor SK Sanksi');
            $table->date('SanksiDate')->nullable()->comment('tanggal SK Sanksi');
            $table->string('SanksiFile', 255)->nullable()->comment('path + orig filename + id perusahaan + epoch time');
            $table->unsignedTinyInteger('StatusPenaatan')->default(1)->comment('1=pengawasan, 2=peningkatan sanksi, 3=taat');
            $table->string('PenaatanNumber', 100)->nullable()->comment('nomor SK penaatan');
            $table->date('PenaatanDate')->nullable()->comment('tanggal SK penaatan');
            $table->string('PenaatanFile', 255)->nullable()->comment('path + orig filename + id perusahaan + epoch time');
            $table->unsignedTinyInteger('IsDeleted')->default(0)->comment('0=false, 1=true');

            $table->index('PerusahaanId');
            $table->index('JenisSanksiId');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('Hukum');
    }
};
