Home / Snippets / How to Rollback Migration Several Steps Back in Laravel
How to Rollback Migration Several Steps Back in Laravel cover

How to Rollback Migration Several Steps Back in Laravel

549

3 years ago

0 comments

To rollback to a previous migration in Laravel you can make use of the "migrate:rollback" command. This is very handy but sometimes you might need to migrate several steps back and although this is not common, there will be times that you need this.
php artisan migrate:rollback
You may roll back a limited number of migrations by providing the step option to the rollback command.
In order to rollback to several steps back, you can make use the "--steps" command and it looks like below. In this case it will go back 3 steps instead of the normal 1 step back.
php artisan migrate:rollback --step=3
Now when you run "migrate" command, your migration will be the one 3 versions ago. If you want to rollback and re-migrate then you can make use of the "migrate:rollback" command.
You may roll back & re-migrate a limited number of migrations by providing the step option to the refresh command
php artisan migrate:rollback --step=5
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this