Merged in afiqhamzah/feat/add-column-migration-checker (pull request #42)
Add column migration checker contd
This commit is contained in:
@@ -14,14 +14,14 @@ class AddTunggakanToGadaiTable extends Migration
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var object $db_connection
|
||||
*/
|
||||
|
||||
|
||||
public function getActiveDB(){
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
|
||||
$db_connection = array_filter($config_db,function($connection){
|
||||
try{
|
||||
if($connection == 'mysql7')
|
||||
@@ -39,14 +39,23 @@ class AddTunggakanToGadaiTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
|
||||
$table->decimal('tunggakanujrah', 9, 2);
|
||||
$table->decimal('tunggakanonepercent', 9, 2);
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use($dbase) {
|
||||
|
||||
$isTunggakanUjrah = Schema::connection($dbase)->hasColumn('gadai', 'tunggakanujrah');
|
||||
$isTunggakkanOnePercent = Schema::connection($dbase)->hasColumn('gadai', 'tunggakanonepercent');
|
||||
|
||||
if (! $isTunggakanUjrah) {
|
||||
$table->decimal('tunggakanujrah', 9, 2);
|
||||
}
|
||||
|
||||
if (! $isTunggakkanOnePercent) {
|
||||
$table->decimal('tunggakanonepercent', 9, 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,4 +75,4 @@ class AddTunggakanToGadaiTable extends Migration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user