New Migrate:Fresh Command (4/14) – Laravel 5.5 New Features

We already have several migration commands and it feels like we get a few new ones with each Laravel release, but I promise that this one is actually worth looking into.

Migrate:fresh works similar to migrate:refresh but with one significant difference. The migrate:refresh command (the command we have had around for a very long time, used to run the down() function for all of our migration files, and then if successfully rolled back everything, it would run the migrations again in the correct order.

This was ok, except when we had an error in our down() functions. This happens for many reasons and not all of them are your fault. For example, sometimes an index can cause the problem, or something a minor typo. But this can be frustrating for developers that can’t successfully reset their database because of some problem in their migration files.

Now with the migrate:fresh command, Laravel simply drops all of the tables as opposed to running the down() functions. This is convenient for us because if you have a problem in the down() function it won’t throw an error. This is also a tad bit faster and over all, it just makes more sense.

I am excited to start working with the migrate:fresh command more and I plan to use it as my “default” command when I want to get a /fresh/ install of my Laravel database tables.


Full Playlist for the “Laravel 5.5 New Features“ Series:

==== FOLLOW ME ====

Subscribe for New Releases!

Subscribe to DevMarketer Insider
[Email Newsletter]

Twitter –
(ask me questions!)

==== QUESTIONS? ====

Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.

Email me

Thanks for all your support!



Build A Site Info