Resetting and Re-running All Migrations

Problem

You want to reset and re-run all your migrations.

Maybe you've made some database changes by hand. You want to get your database to the exact structure a fresh install would have.

Solution

Use the php artisan migrate:refresh command.

$ php artisan migrate:refresh

To reseed the database when complete, you can use the --seed option.

$ php artisan migrate:refresh --seed

Discussion

This command saves a few steps.

Instead of issuing ...

$ php artisan migrate:reset
$ php artisan migrate

This one command combines both functions.

Something to keep in mind. When you clear all your migrations and run migrations again this creates a new migration set. A subsequent migrate:rollback will rollback all migrations performed in this set.

comments powered by Disqus