From 90a58118e363f420597e9506438a172b68974e0b Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 8 Feb 2018 20:19:46 +0300 Subject: [PATCH] Fix FK for Postgresql etc. Works for all databases --- database/seeds/DatabaseSeeder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index cbfb3d0..86212d6 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -12,7 +12,7 @@ class DatabaseSeeder extends Seeder public function run() { if (app()->environment() == 'local') { - DB::statement('SET FOREIGN_KEY_CHECKS=0;'); + Schema::disableForeignKeyConstraints(); $this->call(RolesSeeder::class); $this->call(UsersSeeder::class); @@ -20,7 +20,7 @@ public function run() $this->call(PostsMediaSeeder::class); $this->call(CategoriesSeeder::class); - DB::statement('SET FOREIGN_KEY_CHECKS=1;'); + Schema::enableForeignKeyConstraints(); } if (app()->environment() == 'production') { $this->call(RolesProductionSeeder::class); @@ -28,7 +28,7 @@ public function run() $this->call(PostsProductionSeeder::class); $this->call(CategoriesProductionSeeder::class); - DB::statement('SET FOREIGN_KEY_CHECKS=1;'); + Schema::enableForeignKeyConstraints(); } } }