feat(migrations): add migration for updating details format and adding nomor jaminan to permohonan table

This commit is contained in:
2025-05-07 11:48:32 +07:00
parent 88bf73cbb9
commit 0e3b4786c4
2 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
use Modules\Lpj\Models\DetailDokumenJaminan;
use Illuminate\Support\Facades\DB;
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
{
DetailDokumenJaminan::query()
->whereNotNull('details')
->where('details', '!=', '')
->where('details', 'not like', '[%]')
->update([
'details' => DB::raw("CONCAT('[', details, ']')")
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DetailDokumenJaminan::query()
->whereNotNull('details')
->where('details', '!=', '')
->where('details', 'like', '[%]')
->where('details', 'like', '%]')
->update([
'details' => DB::raw("SUBSTRING(details, 2, LENGTH(details) - 2)")
]);
}
};

View File

@@ -0,0 +1,28 @@
<?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) {
$table->string('mig_mst_lpj_nomor_jaminan')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('permohonan', function (Blueprint $table) {
$table->dropColumn('mig_mst_lpj_nomor_jaminan');
});
}
};