added timestmap for gldetail

This commit is contained in:
hafifierahman
2025-02-26 01:27:49 +08:00
committed by Hafifie PKB
parent 73c8220e1a
commit e966d21417
4 changed files with 183 additions and 10 deletions
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTimestampToGldetailTable 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()
{
$db_connection = $this->getActiveDB();
foreach($db_connection as $dbase){
Schema::connection($dbase)->table('gldetail', function (Blueprint $table) use($dbase) {
$dateCreated = Schema::connection($dbase)->hasColumn('gldetail', 'date_created');
if (!$dateCreated) {
$table->timestamp('date_created');
}
});
}
}
}