<?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('laporan_slik', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('slik_id')->nullable();
            $table->string('sandi_bank', 10)->nullable();
            $table->string('kode_kantor', 10)->nullable();
            $table->string('kode_cabang', 10)->nullable();
            $table->string('tahun', 4)->nullable();
            $table->string('bulan', 2)->nullable();
            $table->string('no_rekening', 50)->nullable();
            $table->string('cif', 50)->nullable();
            $table->string('kode_jenis', 10)->nullable();
            $table->string('kode_jenis_ket', 100)->nullable();
            $table->string('kode_sifat', 10)->nullable();
            $table->string('kode_sifat_ket', 100)->nullable();
            $table->string('kode_valuta', 5)->nullable();
            $table->string('kode_valuta_ket', 50)->nullable();
            $table->string('baki_debet', 20)->nullable();
            $table->string('kolektibilitas', 5)->nullable();
            $table->string('kolektibilitas_ket', 50)->nullable();
            $table->string('tanggal_mulai', 10)->nullable();
            $table->string('tanggal_jatuh_tempo', 10)->nullable();
            $table->string('tanggal_selesai', 10)->nullable();
            $table->string('tanggal_restrukturisasi', 10)->nullable();
            $table->string('kode_sebab_macet', 10)->nullable();
            $table->string('kode_sebab_macet_ket', 100)->nullable();
            $table->string('tanggal_macet', 10)->nullable();
            $table->string('kode_kondisi', 10)->nullable();
            $table->string('kode_kondisi_ket', 100)->nullable();
            $table->string('tanggal_kondisi', 10)->nullable();
            $table->string('nilai_agunan', 20)->nullable();
            $table->string('nilai_agunan_ket', 100)->nullable();
            $table->string('jenis_agunan', 50)->nullable();
            $table->string('kode_agunan', 10)->nullable();
            $table->string('kode_agunan_ket', 100)->nullable();
            $table->string('peringkat_agunan', 10)->nullable();
            $table->string('peringkat_agunan_ket', 100)->nullable();
            $table->string('nama_debitur', 100)->nullable();
            $table->string('npwp', 50)->nullable();
            $table->string('no_ktp', 50)->nullable();
            $table->string('no_telp', 50)->nullable();
            $table->string('kode_kab_kota', 10)->nullable();
            $table->string('kode_kab_kota_ket', 100)->nullable();
            $table->string('kode_negara_domisili', 10)->nullable();
            $table->string('kode_negara_domisili_ket', 100)->nullable();
            $table->string('kode_pos', 10)->nullable();
            $table->string('alamat', 200)->nullable();
            $table->string('fasilitas', 100)->nullable();
            $table->string('status_agunan', 20)->nullable();
            $table->string('tanggal_lapor', 10)->nullable();
            $table->string('status', 20)->default('aktif');
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();
            $table->timestamps();
            
            $table->index('slik_id');
            $table->index('no_rekening');
            $table->index('cif');
            $table->index('nama_debitur');
            $table->index(['tahun', 'bulan']);
            $table->index('created_at');
        });
    }

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