Posted by Arjun Arjun on Saturday 4th January 2020, 1 minute read

Laravel Drop all tables

Laravel

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)]);
}
...
Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.