Add column migration checker contd
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user