fix database migration
This commit is contained in:
@@ -13,6 +13,12 @@ class AddOnepercentToGadaiTable extends Migration
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var object $db_connection
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
public function getActiveDB(){
|
public function getActiveDB(){
|
||||||
$config_db = array_keys(config("database.connections"));
|
$config_db = array_keys(config("database.connections"));
|
||||||
|
|
||||||
@@ -40,6 +46,7 @@ class AddOnepercentToGadaiTable extends Migration
|
|||||||
$table->decimal('ujrah', 9, 2);
|
$table->decimal('ujrah', 9, 2);
|
||||||
$table->decimal('onepercent', 9, 2);
|
$table->decimal('onepercent', 9, 2);
|
||||||
$table->decimal('margin_semasa', 5, 2);
|
$table->decimal('margin_semasa', 5, 2);
|
||||||
|
$table->tinyInteger('tagbaru')->default(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +63,7 @@ class AddOnepercentToGadaiTable extends Migration
|
|||||||
|
|
||||||
foreach($db_connection as $dbase){
|
foreach($db_connection as $dbase){
|
||||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
|
Schema::connection($dbase)->table('gadai', function (Blueprint $table) {
|
||||||
// $table->dropColumn('votes');
|
$table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa','tagbaru']);
|
||||||
$table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa']);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ class AddOnepercentToKadarupahTable extends Migration
|
|||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::connection('mysql7')->table('kadarupah', function (Blueprint $table) {
|
Schema::connection('mysql7')->table('kadarupah', function (Blueprint $table) {
|
||||||
$table->dropColumn(['kadarujrah', 'kadaronepercent']);
|
$table->dropColumn(['kadarujrah','kadaronepercent']);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddOnepercentToTransactionKeuntunganTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||||
|
$table->decimal('ujrah', 5, 2);
|
||||||
|
$table->decimal('ujrah_rebet', 5, 2);
|
||||||
|
$table->decimal('onepercent', 5, 2);
|
||||||
|
$table->decimal('onepercent_rebet', 5, 2);
|
||||||
|
$table->decimal('tempoh', 5, 2);
|
||||||
|
$table->decimal('beza_tempoh', 5, 2);
|
||||||
|
$table->decimal('margin_semasa', 5, 2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['ujrah', 'ujrah_rebet', 'onepercent', 'onepercent_rebet', 'tempoh', 'beza_tempoh', 'margin_semasa']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddOnepercentToTebusTable 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('tebus', function (Blueprint $table) {
|
||||||
|
$table->decimal('ujrah', 9, 2);
|
||||||
|
$table->decimal('onepercent', 9, 2);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$db_connection = $this->getActiveDB();
|
||||||
|
|
||||||
|
foreach($db_connection as $dbase){
|
||||||
|
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['ujrah', 'onepercent']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user