<?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('Perusahaan', function (Blueprint $table) {
            $table->id('PerusahaanId');
            $table->string('NomorInduk')->nullable();
            $table->unsignedBigInteger('JenisKegiatanId');
            $table->foreign('JenisKegiatanId')->references('JenisKegiatanId')->on('JenisKegiatan')->onDelete('cascade');
            $table->string('NamaPerusahaan');
            $table->string('Alamat')->nullable();
            $table->unsignedBigInteger('KelurahanId');
            $table->foreign('KelurahanId')->references('KelurahanId')->on('Kelurahan')->onDelete('cascade');
            $table->string('KodePos')->nullable();
            $table->string('Telepon')->nullable();
            $table->string('Fax')->nullable();
            $table->string('Email')->nullable();
            $table->string('Lintang')->nullable();
            $table->string('Bujur')->nullable();
            $table->string('CPNama')->nullable();
            $table->string('CPTelepon')->nullable();
            $table->string('ILNomor')->nullable();
            $table->string('ILTanggal')->nullable();
            $table->string('ILDokumen')->nullable();
            $table->unsignedBigInteger('JenisDokILId');
            $table->foreign('JenisDokILId')->references('JenisDokILId')->on('JenisDokIL')->onDelete('cascade');
            $table->unsignedBigInteger('VerifikatorId');
            $table->foreign('VerifikatorId')->references('VerifikatorId')->on('Verifikator')->onDelete('cascade');
            $table->boolean('ReportLocked')->default(1);
            $table->boolean('IsPublish')->default(1);


            $table->timestamps();
            $table->index('NomorInduk', 'IndexNomorInduk');
            $table->index('KelurahanId', 'IndexKelurahanId');
        });
    }

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