To rollback a specific migration in Laravel, “pass the –step argument to the migrate:rollback command.”
Here’s how to rollback the last batch of migrations by one step:
- Navigate to your Laravel project root directory.
- Run the following command:
php artisan migrate:rollback --step=1
The –step option allows you to specify how many batches of migrations you want to roll back. In this case, specifying –step=1 will roll back the last batch.
Note: It’s always a good practice to back up your database before rolling back any migrations, especially in a production environment.
You can rollback and re-migrate a limited number of migrations by providing the step option to the refresh command.
For example, the following command will rollback & re-migrate the last two migrations:
php artisan migrate:refresh --step=2
You can roll back a limited number of migrations by providing the step option to the rollback command.
For example, the following command will rollback the last three migrations:
php artisan migrate:rollback --step=3