Add column migration checker contd

This commit is contained in:
Afiq Hamzah
2023-12-14 18:04:18 +08:00
parent f6110cfb9b
commit d82dd37c81
2 changed files with 20 additions and 40 deletions
@@ -44,15 +44,31 @@ class AddOnepercentToGadaiTable extends Migration
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use($dbase) {
$isKadarUjrahExist = Schema::connection($dbase)->hasColumn('gadai', 'kadarujrah');
$isUjrahExist = Schema::connection($dbase)->hasColumn('gadai', 'ujrah');
$isOnePercentExist = Schema::connection($dbase)->hasColumn('gadai', 'onepercent');
$isMarginSemasaExist = Schema::connection($dbase)->hasColumn('gadai', 'margin_semasa');
$isTagbaruExist = Schema::connection($dbase)->hasColumn('gadai', 'tagbaru');
if(! $isKadarUjrahExist){
$table->decimal('kadarujrah', 5, 2);
}
$table->decimal('ujrah', 9, 2);
$table->decimal('onepercent', 9, 2);
$table->decimal('margin_semasa', 5, 2);
$table->tinyInteger('tagbaru')->default(0);
if(! $isUjrahExist){
$table->decimal('ujrah', 9, 2);
}
if(! $isOnePercentExist){
$table->decimal('onepercent', 9, 2);
}
if(! $isMarginSemasaExist){
$table->decimal('margin_semasa', 5, 2);
}
if(! $isTagbaruExist){
$table->tinyInteger('tagbaru')->default(0);
}
});
}
@@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateHistoryOnepercentTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('history_onepercent', function (Blueprint $table) {
$table->id();
$table->decimal('tempoh', 10, 2);
$table->decimal('ujrah', 10, 2);
$table->decimal('onepercent', 10, 2);
$table->decimal('margin_semasa', 5, 2);
$table->decimal('bakipinjaman', 10, 2);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('history_onepercent');
}
}