Rollback a specific migration in Laravel
There comes a time when you want to make some changes to an existing table. For instance, you want to change the data type of a column. So, in this case, you can modify the migration file of the table and then run the migration again using the
artisan migrate:refresh command like so.
php artisan migrate:refresh
But what this will do is that it will rollback all the migrations and then run them again. Essentially, this command effectively re-creates your entire database. And you might not want to do that.
If you only want to rollback a specific migration, you can pass in a
--pathoption to the
artisan migrate:refreshcommand and specify the path to the migration file you want to rollback.
For instance, if you want to rollback the
2014_10_12_100000_create_password_resets_table migration, you can do so like so.
php artisan migrate:refresh --path=database/migrations/2014_10_12_100000_create_password_resets_table.php
Here’s what this might look like.
As you can tell, this will only rollback the
2014_10_12_100000_create_password_resets_table migration and then run it again leaving the rest of the migrations untouched.
Like this article? Consider leaving aTip