Skip to content

Laravel Drop all tables

Last updated on January 30, 2021

This is useful for migrations when you can’t rollback. It can easily be run in artisan mode or you can create a console command.

foreach(\DB::select('SHOW TABLES') as $table) {
    $table_array = get_object_vars($table);
    \Schema::drop($table_array[key($table_array)]);
}
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments