Last active
January 22, 2019 17:20
-
-
Save Fogggy/bb49f01870adfdd8df911c0caa77fda8 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
Artisan::command('drop-tables', function () { | |
if ($this->confirm("Dude, are you sure that you really want to drop all the tables in the database? All your data will be lost!") && | |
$this->ask("Type 'drop tables' to confirm operation") == 'drop tables') { | |
Schema::dropAllTables(); | |
/** | |
* Drop Functions | |
*/ | |
$functions = DB::select(sprintf("SHOW FUNCTION STATUS WHERE Db = '%s';", DB::getDatabaseName())); | |
foreach ($functions as $function) { | |
DB::statement(sprintf("DROP FUNCTION %s", $function->name)); | |
} | |
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames(); | |
$functions = DB::select(sprintf("SHOW FUNCTION STATUS WHERE Db = '%s';", DB::getDatabaseName())); | |
$this->info('Done!'); | |
$this->line(str_repeat('-', 30)); | |
$this->comment('Database: '.DB::getDatabaseName()); | |
$this->comment('Count Tables: '.count($tables)); | |
$this->comment('Count Functions: '.count($functions)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment