You may be familiar with the
migrate:refresh command that allows you to rollback and re-runs all of your migrations. This helps when you need to rebuild your database during development.
Coming to Laravel 5.5 is an improvement on this with a new command named
migrate:fresh. The difference between “refresh” and “fresh” is that the new fresh command skips all the down methods or the rollback by dropping the tables, then running through the
Here is the command output showing the differences:
$ php artisan migrate:refresh Rolling back: 2014_10_12_100000_create_password_resets_table Rolled back: 2014_10_12_100000_create_password_resets_table Rolling back: 2014_10_12_000000_create_users_table Rolled back: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table
Now, with the new fresh command:
$ php artisan migrate:fresh Dropped all tables successfully. Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table
What is also beneficial with this new command is it pairs well with the recent 5.4.17 release because it made the
down methods in migrations optional. Now you can leave off the down and still quickly reset your local database.
migrate:fresh will be included in Laravel 5.5 that is scheduled to be released in July or August of this year. For more information on this new feature, you can also check out Taylor’s announcement post.
Update: If you’d like to utilize on your current Laravel app check out this package by Spatie.