Add column migration checker contd
This commit is contained in:
@@ -18,18 +18,19 @@ class AddColumnUjrahStokauditbackdate extends Migration
|
|||||||
* @var object $db_connection
|
* @var object $db_connection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public function getActiveDB()
|
||||||
public function getActiveDB(){
|
{
|
||||||
$config_db = array_keys(config("database.connections"));
|
$config_db = array_keys(config("database.connections"));
|
||||||
|
|
||||||
$db_connection = array_filter($config_db,function($connection){
|
$db_connection = array_filter($config_db, function ($connection) {
|
||||||
try{
|
try {
|
||||||
if($connection == 'mysql7')
|
if ($connection == 'mysql7') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$db = DB::connection($connection)->getPdo();
|
$db = DB::connection($connection)->getPdo();
|
||||||
return true;
|
return true;
|
||||||
} catch(\Exception $e){
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -40,82 +41,168 @@ class AddColumnUjrahStokauditbackdate extends Migration
|
|||||||
{
|
{
|
||||||
$db_connection = $this->getActiveDB();
|
$db_connection = $this->getActiveDB();
|
||||||
|
|
||||||
foreach($db_connection as $dbase){
|
foreach ($db_connection as $dbase) {
|
||||||
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table){
|
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table) use ($dbase) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table){
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit1', 'utgonepercent');
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit1', 'ujrah');
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit3', function (Blueprint $table){
|
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit4', function (Blueprint $table){
|
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit5', function (Blueprint $table){
|
|
||||||
|
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit6', function (Blueprint $table){
|
|
||||||
|
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit7', function (Blueprint $table){
|
|
||||||
|
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
|
||||||
$table->decimal('ujrah', 9, 2);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit8', function (Blueprint $table){
|
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table){
|
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit2', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit2', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table){
|
Schema::connection($dbase)->table('stokaudit3', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit3', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit3', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table){
|
Schema::connection($dbase)->table('stokaudit4', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit4', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit4', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table){
|
Schema::connection($dbase)->table('stokaudit5', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit5', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit5', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
$table->decimal('utgonepercent', 9, 2);
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
};
|
Schema::connection($dbase)->table('stokaudit6', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit6', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit6', 'ujrah');
|
||||||
|
|
||||||
}
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit7', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit7', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit7', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit8', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit8', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit8', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit9', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit9', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit10', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit10', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit11', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit11', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table) use ($dbase) {
|
||||||
|
$isUtGonePercentExist = Schema::connection($dbase)->hasColumn('stokaudit12', 'utgonepercent');
|
||||||
|
$isUjrahExist = Schema::connection($dbase)->hasColumn('stokaudit12', 'ujrah');
|
||||||
|
|
||||||
|
if ($isUtGonePercentExist) {
|
||||||
|
$table->decimal('utgonepercent', 9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isUjrahExist) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
@@ -126,51 +213,51 @@ class AddColumnUjrahStokauditbackdate extends Migration
|
|||||||
{
|
{
|
||||||
$db_connection = $this->getActiveDB();
|
$db_connection = $this->getActiveDB();
|
||||||
|
|
||||||
foreach($db_connection as $dbase){
|
foreach ($db_connection as $dbase) {
|
||||||
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit3', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit3', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
Schema::connection($dbase)->table('stokaudit4', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit4', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit5', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit5', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit6', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit6', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit7', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit7', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit8', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit8', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table) {
|
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table) {
|
||||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user