Merge branch 'production' of https://bitbucket.org/arrahn-pkb/api_arrahn into annur-rebate

This commit is contained in:
nurafrinaalimi16
2025-01-26 12:56:45 +08:00
41 changed files with 2928 additions and 531 deletions
@@ -0,0 +1,73 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddColumnTimestampToAddtunaiTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
protected $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()
{
$this->db_connection = $this->getActiveDB();
foreach($this->db_connection as $dbase){
Schema::connection($dbase)->table('addtunai', function (Blueprint $table) use($dbase) {
$isCreatedAt = Schema::connection($dbase)->hasColumn('addtunai', 'created_at');
if (! $isCreatedAt) {
$table->timestamp('created_at');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$this->db_connection = $this->getActiveDB();
foreach($this->db_connection as $dbase){
$columns = ['created_at'];
$columns_exist = array_filter($columns,function($column) use($dbase){
return Schema::connection($dbase)->hasColumn('addtunai', $column);
});
Schema::connection($dbase)->table('addtunai', function(Blueprint $table) use($columns_exist){
foreach($columns_exist as $column){
$table->dropColumn($column);
}
});
}
}
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRecnoToRequestTellerTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$columns = ['recno'];
$columns_not_exist = array_filter($columns, function ($column) {
return !Schema::connection('mysql7')->hasColumn('requestteller', $column);
});
Schema::connection('mysql7')->table('requestteller', function (Blueprint $table) use ($columns_not_exist) {
array_walk($columns_not_exist, function ($column) use ($table) {
$table->integer($column);
});
});
}
}
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotaPekerjaan extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
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()
{
Schema::connection('mysql7')->table('customer', function (Blueprint $table) {
$table->string('nota_pekerjaan')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customer', function (Blueprint $table) {
$table->dropColumn('nota_pekerjaan');
});
}
}