feat(migrations): add migration for updating details format and adding nomor jaminan to permohonan table
This commit is contained in:
@@ -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)")
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user