Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKadarRebetTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Master DB (mysql7) — Annur rebet bands by pembiayaan range.
|
||||
* Empty table + feature flag off = other cawangan unchanged.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::connection('mysql7')->hasTable('kadar_rebet')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::connection('mysql7')->create('kadar_rebet', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->decimal('pembiayaan_min', 12, 2)->default(0);
|
||||
$table->decimal('pembiayaan_max', 12, 2)->default(0);
|
||||
$table->decimal('kadarrebet', 8, 4)->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection('mysql7')->dropIfExists('kadar_rebet');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddAnnurDiskaunColumns extends Migration
|
||||
{
|
||||
public function getActiveDB()
|
||||
{
|
||||
$config_db = array_keys(config('database.connections'));
|
||||
|
||||
return array_filter($config_db, function ($connection) {
|
||||
try {
|
||||
if ($connection === 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||
$addKadar = !Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet');
|
||||
$addDiskaun = !Schema::connection($dbase)->hasColumn('gadai', 'diskaun');
|
||||
if ($addKadar || $addDiskaun) {
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($addKadar, $addDiskaun) {
|
||||
if ($addKadar) {
|
||||
$table->decimal('kadarrebet', 8, 4)->nullable()->default(0);
|
||||
}
|
||||
if ($addDiskaun) {
|
||||
$table->decimal('diskaun', 12, 2)->nullable()->default(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection($dbase)->hasTable('tebus')
|
||||
&& !Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||
) {
|
||||
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||
$table->decimal('diskaun_rebate', 12, 2)->nullable()->default(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||
&& !Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||
) {
|
||||
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||
$table->decimal('kadardiskaun', 12, 2)->nullable()->default(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($dbase) {
|
||||
$drops = [];
|
||||
if (Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet')) {
|
||||
$drops[] = 'kadarrebet';
|
||||
}
|
||||
if (Schema::connection($dbase)->hasColumn('gadai', 'diskaun')) {
|
||||
$drops[] = 'diskaun';
|
||||
}
|
||||
if ($drops) {
|
||||
$table->dropColumn($drops);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection($dbase)->hasTable('tebus')
|
||||
&& Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||
) {
|
||||
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||
$table->dropColumn('diskaun_rebate');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||
&& Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||
) {
|
||||
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||
$table->dropColumn('kadardiskaun');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddPcVerifiedToPembiayaanOnlineTable extends Migration
|
||||
{
|
||||
public function getActiveDB()
|
||||
{
|
||||
return array_filter(
|
||||
array_keys(config('database.connections')),
|
||||
function ($connection) {
|
||||
try {
|
||||
if ($connection === 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::connection($connection)->getPdo();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (!Schema::connection($dbase)->hasTable('pembiayaan_online')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::connection($dbase)->table('pembiayaan_online', function (Blueprint $table) use ($dbase) {
|
||||
if (!Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_by')) {
|
||||
$table->string('pc_verified_by', 100)
|
||||
->nullable()
|
||||
->after('pc_submitted_by');
|
||||
}
|
||||
|
||||
if (!Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_at')) {
|
||||
$table->timestamp('pc_verified_at')
|
||||
->nullable()
|
||||
->after('pc_verified_by');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (!Schema::connection($dbase)->hasTable('pembiayaan_online')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::connection($dbase)->table('pembiayaan_online', function (Blueprint $table) use ($dbase) {
|
||||
$cols = [];
|
||||
if (Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_at')) {
|
||||
$cols[] = 'pc_verified_at';
|
||||
}
|
||||
if (Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_by')) {
|
||||
$cols[] = 'pc_verified_by';
|
||||
}
|
||||
if (!empty($cols)) {
|
||||
$table->dropColumn($cols);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user