Can anyone tell me how I can roll back a specific migration file and migrate it again in Laravel? I only added some changes to a migration file which is middle of my migration file list. I don’t want to migrate:refresh and clear the entire database, I want to roll back that specific file. Is there a way to do this using the Artisan command line interface?
To rollback a specific migration in Laravel, you can use the below artisan migrate:rollback command. The --path= option allows you to target a specific migration file and undo its changes to the database schema.
To revert the latest migration in Laravel, you can use the following command:
php artisan migrate:rollback --step=1
The --step=1 parameter tells Laravel only to undo the most recent migration. You can adjust the number to undo multiple migrations. For example, use --step=2 to revert the last two migrations.