Penambahn P1 Dev
This commit is contained in:
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rekapitulasi.p1_penyesuaian', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nip');
|
||||
$table->integer('tahun');
|
||||
$table->integer('bulan');
|
||||
$table->integer('tahun_pembayaran');
|
||||
$table->integer('bulan_pembayaran');
|
||||
$table->json('sebelum');
|
||||
$table->json('sesudah');
|
||||
$table->json('tmt');
|
||||
$table->date('tst');
|
||||
$table->timestamps();
|
||||
$table->unique(['nip', 'tahun', 'bulan', 'tahun_pembayaran', 'bulan_pembayaran'], 'p1_penyesuaian_periode_unique');
|
||||
$table->index(['tahun_pembayaran', 'bulan_pembayaran']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rekapitulasi.p1_penyesuaian');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
foreach (['gaji_yang_dibayarkan_final', 'pph_21_final', 'gaji_bersih_final'] as $column) {
|
||||
if (! Schema::connection('rekapitulasi')->hasColumn('p1', $column)) {
|
||||
Schema::connection('rekapitulasi')->table('p1', function (Blueprint $table) use ($column) {
|
||||
$table->decimal($column, 18, 2)->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Preserve payment history and columns that may predate this migration.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection('rekapitulasi');
|
||||
$connection = DB::connection('rekapitulasi');
|
||||
$connection->transaction(function () use ($schema, $connection) {
|
||||
foreach (['gaji_p1_yang_dibayarkan_final' => 'gaji_yang_dibayarkan_final', 'pph21_final' => 'pph_21_final'] as $duplicate => $existing) {
|
||||
if (! $schema->hasColumn('p1', $duplicate)) {
|
||||
continue;
|
||||
}
|
||||
// Refuse to discard conflicting payment history.
|
||||
if ($connection->table('p1')->whereNotNull($duplicate)->whereNotNull($existing)
|
||||
->whereColumn($duplicate, '<>', $existing)->exists()) {
|
||||
throw new RuntimeException("Nominal {$duplicate} berbeda dari {$existing}; rekonsiliasi diperlukan sebelum penghapusan.");
|
||||
}
|
||||
$connection->table('p1')->whereNull($existing)->whereNotNull($duplicate)
|
||||
->update([$existing => DB::raw('"'.$duplicate.'"')]);
|
||||
$schema->table('p1', function (Blueprint $table) use ($duplicate) {
|
||||
$table->dropColumn($duplicate);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Keep the original schema and the reconciled payment history.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::connection('rekapitulasi')->hasColumn('p1', 'status_pegawai')) {
|
||||
Schema::connection('rekapitulasi')->table('p1', function (Blueprint $table) {
|
||||
$table->string('status_pegawai')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection('rekapitulasi')->table('p1', function (Blueprint $table) {
|
||||
$table->dropColumn('status_pegawai');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user