Created
March 23, 2018 00:51
-
-
Save andri-sudarmawijaya/4a382b5112b91537bb2023ca3d3a3aaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Seeder; | |
class DatabaseSeeder extends Seeder | |
{ | |
/** | |
* Run the database seeds. | |
* | |
* @return void | |
*/ | |
public function run() | |
{ | |
// $this->call(UsersTableSeeder::class); | |
Eloquent::unguard(); | |
DB::beginTransaction(); | |
//disable foreign key check for this connection before running see$ | |
//DB::statement('SET FOREIGN_KEY_CHECKS=0;'); | |
//turn off referential integrity | |
//DB::statement('SET FOREIGN_KEY_CHECKS = 0'); | |
DB::statement("TRUNCATE TABLE oauth_providers CASCADE;"); | |
DB::statement("TRUNCATE TABLE users CASCADE;"); | |
DB::statement("DROP TABLE oauth_providers;"); | |
DB::statement("DROP TABLE users;"); | |
//turn referential integrity back on | |
//DB::statement('SET FOREIGN_KEY_CHECKS = 1'); | |
// supposed to only apply to a single connection and reset it's se$ | |
// but I like to explicitly undo what I've done for clarity | |
//DB::statement('SET FOREIGN_KEY_CHECKS=1;'); | |
DB::commit(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment