Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andri-sudarmawijaya/4a382b5112b91537bb2023ca3d3a3aaa to your computer and use it in GitHub Desktop.
Save andri-sudarmawijaya/4a382b5112b91537bb2023ca3d3a3aaa to your computer and use it in GitHub Desktop.
<?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