Skip to content

Instantly share code, notes, and snippets.

@locopine
Forked from sohelamin/drop-table
Created January 12, 2023 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save locopine/3f8d9721e9cf3995fbc8427aac667bdf to your computer and use it in GitHub Desktop.
Save locopine/3f8d9721e9cf3995fbc8427aac667bdf to your computer and use it in GitHub Desktop.
Laravel drop tables via artisan command
php artisan tinker
$tables = DB::select('SHOW TABLES');
$tables_in_database = "Tables_in_".Config::get('database.connections.mysql.database');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($tables as $table) {
Schema::drop($table->$tables_in_database);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment