add column to stokaudit
This commit is contained in:
committed by
Hafifie PKB
parent
ff9e7d8d46
commit
69e3613e01
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddColumnUjrahStokauditbackdate extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @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')
|
||||
return false;
|
||||
|
||||
$db = DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch(\Exception $e){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection;
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table){
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table){
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$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){
|
||||
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table){
|
||||
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table){
|
||||
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table){
|
||||
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table){
|
||||
|
||||
$table->decimal('utgonepercent', 9, 2);
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
Schema::connection($dbase)->table('stokaudit1', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit2', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit3', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
Schema::connection($dbase)->table('stokaudit4', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit5', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit6', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit7', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit8', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit9', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit10', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit11', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('stokaudit12', function (Blueprint $table) {
|
||||
$table->dropColumn(['utgonepercent', 'ujrah']);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user