Add new columns to komuditi_transaksi
This commit is contained in:
+2
-3
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'default' => 'accounts',
|
'default' => 'mysql7',
|
||||||
|
'migrations' => 'migrations',
|
||||||
'connections' => [
|
'connections' => [
|
||||||
'lelong' => [
|
'lelong' => [
|
||||||
'driver' => 'mysql',
|
'driver' => 'mysql',
|
||||||
@@ -451,4 +451,3 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddColumnsToKomuditiTransaksi extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection($this->getOnlineArrahnConnection())->table('komuditi_transaksi', function (Blueprint $table){
|
||||||
|
$table->string('customer_id', 10, 2)->after('nosijil');
|
||||||
|
$table->float('harga', 10, 2)->after('nosijil');
|
||||||
|
$table->float('tan', 10, 2)->after('nosijil');
|
||||||
|
$table->string('no_sijil_pelanggan')->after('nosijil')->comment('format: no sijil bursa + no siri PKB');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection($this->getOnlineArrahConnection())->table('komuditi_transaksi', function (Blueprint $table){
|
||||||
|
$table->dropColumn('no_sijil_pelanggan');
|
||||||
|
$table->dropColumn('tan');
|
||||||
|
$table->dropColumn('harga');
|
||||||
|
$table->dropColumn('customer_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getOnlineArrahnConnection()
|
||||||
|
{
|
||||||
|
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
||||||
|
|
||||||
|
if($connection['database'] === 'online_arrahn'){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($online_arrahn_connection_array)){
|
||||||
|
throw new Exception("online_arrahn doesn't exist in config.database.connections array");
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_keys($online_arrahn_connection_array)[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user