Posts Learn Components Snippets Categories Tags Tools 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

534 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

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

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Sponsors 👑

+ Add Yours
)