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?
php artisan migrate:rollback 2022_08_31_165946_create_budget_entries_table.php
I tried this but obviously, it didn’t work.
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.
php artisan migrate:rollback --path=\database\migrations\2022_08_31_165946_create_budget_entries_table.php
To revert the latest migration in Laravel, you can use the following command:
php artisan migrate:rollback --step=1
--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.