fix seed contraints error

This commit is contained in:
Jack Goh
2018-07-08 11:50:36 +08:00
parent 72a4f6645f
commit 766316572c
5 changed files with 48 additions and 0 deletions
@@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeForeignkeyTypeInActivebankTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('setting_active_banks', function(Blueprint $table)
{
$table->dropForeign('setting_active_banks_x1_bank_id_foreign');
$table->foreign('x1_bank_id')
->references('acc_no')->on('setting_malaysia_banks');
$table->dropForeign('setting_active_banks_x2_bank_id_foreign');
$table->foreign('x2_bank_id')
->references('acc_no')->on('setting_malaysia_banks');
$table->dropForeign('setting_active_banks_beneficiary_id_foreign');
$table->foreign('beneficiary_id')
->references('acc_no')->on('setting_beneficiaries');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
+4
View File
@@ -12,6 +12,8 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
Eloquent::unguard();
$this->call(UsersTableSeeder::class);
$this->call(RolesAndPermissionsSeeder::class);
$this->call(UserRoleSeeder::class);
@@ -20,8 +22,10 @@ class DatabaseSeeder extends Seeder
$this->call(SettingCreditSeeder::class);
$this->call(SuppliersTableSeeder::class);
$this->call(MarkingSeeder::class);
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
$this->call(SettingMalaysiaBankSeeder::class);
$this->call(SettingBeneficiaresSeeder::class);
$this->call(SettingActiveBankSeeder::class);
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
}
@@ -11,6 +11,7 @@ class SettingActiveBankSeeder extends Seeder
*/
public function run()
{
DB::table('setting_active_banks')->truncate();
DB::table('setting_active_banks')->insert([
'x1_bank_id' => 'malaysiaacc01',
'x2_bank_id' => 'malaysiaacc02',
@@ -11,6 +11,7 @@ class SettingBeneficiaresSeeder extends Seeder
*/
public function run()
{
DB::table('setting_beneficiaries')->truncate();
DB::table('setting_beneficiaries')->insert([
'company_name' => 'CIEF2',
'bank_name' => 'Mayban222k',
@@ -11,6 +11,7 @@ class SettingMalaysiaBankSeeder extends Seeder
*/
public function run()
{
DB::table('setting_active_banks')->truncate();
DB::table('setting_malaysia_banks')->truncate();
DB::table('setting_malaysia_banks')->insert([
'company_name' => 'CIEF',