Skip to content

jondiscipulo/laravel-artisan-droptables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

Drop Tables: Artisan Command for Laravel 4.2

php artisan drop:tables

Artisan Command for Laravel 4.2 that drops pre-determined tables. This solves foreign key constraint problems when deleting tables with foreign keys.

Practical use of this is after migrating and seeding. Along with several updates, you want to drop the tables, with and without foreign keys, so you can freshly migrate and seed again.

Copy DropTables.php to your project directory:

app/commands/DropTables.php

Add this line to your app/start/artisan.php:

Artisan::add(new DropTables);

Edit app/commands/DropTables.php and change the $tables array with the names of your database tables you want dropped.

protected $tables = [
    'assigned_roles',
    'password_reminders',
    'permission_role',
    'permissions',
    'roles',
    'users',
];

Run the artisan command:

php artisan drop:tables

Disclaimer

This is not intended for production use as this will deliberately drop tables with or without data.

Author

Jon Discipulo

About

Artisan command to drop pre-determined database tables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages