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:
1$ php artisan migrate:refresh23Rolling back: 2014_10_12_100000_create_password_resets_table4Rolled back: 2014_10_12_100000_create_password_resets_table5Rolling back: 2014_10_12_000000_create_users_table6Rolled back: 2014_10_12_000000_create_users_table7Migrating: 2014_10_12_000000_create_users_table8Migrated: 2014_10_12_000000_create_users_table9Migrating: 2014_10_12_100000_create_password_resets_table10Migrated: 2014_10_12_100000_create_password_resets_table
Now, with the new fresh command:
1$ php artisan migrate:fresh23Dropped all tables successfully.4Migration table created successfully.5Migrating: 2014_10_12_000000_create_users_table6Migrated: 2014_10_12_000000_create_users_table7Migrating: 2014_10_12_100000_create_password_resets_table8Migrated: 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.