Posts Learn Components new Snippets new Categories Tags About
/

How to Rollback Migration Several Steps Back in Laravel

Learn how to rollback a migration to several steps back in Laravel the easy way. Make use of this method to go to previous migration steps and get to the migration to migrate.

Created on Oct 01, 2021

36 views

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
new

If you like our tutorial, do make sure to support us with some coffee. We need the juice to write the content during the night 🤙🏻