feat(migration): Tambah kolom migrasi & penyesuaian nullable di beberapa tabel

- Tambah kolom mig_*, is_mig, processed_at, nomor_lpj di tabel debitur, permohonan, jaminan, pemilik_jaminan, inspeksi, dan penilai
- Ubah beberapa field (branch_id, user_id, cif, nomor_id) menjadi nullable untuk fleksibilitas migrasi
- Tambah kolom biaya (decimal(15,2)) pada tabel nilai_plafond
- Pastikan semua kolom baru memiliki mekanisme rollback (down method)
- Perbaikan kompatibilitas migrasi data LPJ lama ke skema baru
- Penyesuaian tipe data & default value sesuai kebutuhan integrasi
- Menambahkan komentar sumber data LPJ lama pada beberapa kolom
- Meningkatkan traceability melalui kolom processed_at
- Menandai data hasil migrasi dengan flag is_mig
- Menjaga integritas dan konsistensi antar tabel selama proses migrasi
This commit is contained in:
Daeng Deni Mardaeni
2025-11-10 09:30:39 +07:00
parent 3ce84b89b4
commit 7f9c58aabe
7 changed files with 267 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?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::table('debitures', function (Blueprint $table) {
// nullable
$table->string('cif', 16)
->nullable()
->default('0000000000')
->comment('asal data LPJ.PRM_DEBITUR.KODE_CIF. Pada KODE_CIF ada yang digitnya 16 => 3372040405810002')
->change();
$table->unsignedBigInteger('branch_id')->nullable()->change();
$table->string('nomor_id', 50)->nullable()->change();
$table->unsignedBigInteger('mig_kd_debitur_seq')->nullable()->comment('asal data LPJ.PRM_DEBITUR.KD_DEBITUR_SEQ. Berguna untuk update debitur_id menggunakan KD_DEBITUR_SEQ nya');
$table->timestamp('processed_at')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('debitures', function (Blueprint $table) {
// Kembalikan kolom branch_id agar tidak nullable (asumsi awal NOT NULL)
$table->unsignedBigInteger('branch_id')->nullable(false)->change();
// Kembalikan kolom yang diubah nullable menjadi NOT NULL
$table->string('cif', 10)->nullable(false)->change();
$table->string('nomor_id', 50)->nullable(false)->change();
// Hapus kolom tambahan yang dibuat di up()
$table->dropColumn([
'mig_kd_debitur_seq',
'mig_urut_seq_addr',
'mig_urut_seq_comm',
'processed_at',
'is_mig'
]);
});
}
};

View File

@@ -0,0 +1,47 @@
<?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::table('permohonan', function (Blueprint $table) {
// nullable
$table->unsignedBigInteger('branch_id')->nullable()->change();
$table->unsignedBigInteger('user_id')->nullable()->change();
$table->unsignedBigInteger('mig_kd_debitur_seq')->nullable()->comment('asal data LPJ.PRM_DEBITUR.KD_DEBITUR_SEQ. Berguna untuk update debitur_id menggunakan KD_DEBITUR_SEQ nya');
$table->unsignedBigInteger('nomor_lpj')->nullable();
$table->string('mig_nama_ao')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('permohonan', function (Blueprint $table) {
// Kembalikan kolom branch_id agar tidak nullable (asumsi awal NOT NULL)
$table->unsignedBigInteger('branch_id')->nullable(false)->change();
$table->unsignedBigInteger('user_id')->nullable(false)->change();
// Hapus kolom tambahan yang dibuat di up()
$table->dropColumn([
'mig_kd_debitur_seq',
'nomor_lpj',
'mig_nama_ao',
'is_mig'
]);
});
}
};

View File

@@ -0,0 +1,40 @@
<?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::table('dokumen_jaminan', function (Blueprint $table) {
// nullable
$table->unsignedBigInteger('mig_kd_debitur_seq')->nullable()->comment('asal data LPJ.PRM_DEBITUR.KD_DEBITUR_SEQ. Berguna untuk update debitur_id menggunakan KD_DEBITUR_SEQ nya');
$table->unsignedBigInteger('nomor_lpj')->nullable();
$table->timestamp('processed_at')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('dokumen_jaminan', function (Blueprint $table) {
// Hapus kolom tambahan yang dibuat di up()
$table->dropColumn([
'nomor_lpj',
'mig_kd_debitur_seq',
'processed_at',
'is_mig'
]);
});
}
};

View File

@@ -0,0 +1,38 @@
<?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::table('pemilik_jaminan', function (Blueprint $table) {
// nullable
$table->unsignedBigInteger('mig_kd_debitur_seq')->nullable()->comment('asal data LPJ.PRM_DEBITUR.KD_DEBITUR_SEQ. Berguna untuk update debitur_id menggunakan KD_DEBITUR_SEQ nya');
$table->timestamp('processed_at')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pemilik_jaminan', function (Blueprint $table) {
// Hapus kolom tambahan yang dibuat di up()
$table->dropColumn([
'mig_kd_debitur_seq',
'processed_at',
'is_mig'
]);
});
}
};

View File

@@ -0,0 +1,32 @@
<?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::table('inspeksi', function (Blueprint $table) {
$table->unsignedBigInteger('nomor_lpj')->nullable();
$table->timestamp('processed_at')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('inspeksi', function (Blueprint $table) {
$table->dropColumn('nomor_lpj');
$table->dropColumn('processed_at');
$table->dropColumn('is_mig');
});
}
};

View File

@@ -0,0 +1,33 @@
<?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::table('penilai', function (Blueprint $table) {
$table->unsignedBigInteger('nomor_lpj')->nullable();
$table->timestamp('processed_at')->nullable();
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penilai', function (Blueprint $table) {
$table->dropColumn('nomor_lpj');
$table->dropColumn('processed_at');
$table->dropColumn('is_mig');
});
}
};

View File

@@ -0,0 +1,25 @@
<?php
return new class extends \Illuminate\Database\Migrations\Migration
{
/**
* Tambah kolom biaya pada tabel nilai_plafond.
*/
public function up(): void
{
\Illuminate\Support\Facades\Schema::table('nilai_plafond', function (\Illuminate\Database\Schema\Blueprint $table) {
// PostgreSQL akan memetakan decimal ke numeric
$table->decimal('biaya', 15, 2)->default(0);
});
}
/**
* Menghapus kolom biaya jika dilakukan rollback.
*/
public function down(): void
{
\Illuminate\Support\Facades\Schema::table('nilai_plafond', function (\Illuminate\Database\Schema\Blueprint $table) {
$table->dropColumn('biaya');
});
}
};