Reputation: 1020
As per laravel doc, To rollback the latest migration operation, you may use the rollback command. This command rolls back the last "batch" of migrations, which may include multiple migration files:
php artisan migrate:rollback
You may rollback a limited number of migrations by providing the step option to the rollback command. For example, the following command will rollback the last five migrations:
php artisan migrate:rollback --step=5
The migrate:reset command will roll back all of your application's migrations:
php artisan migrate:reset
You can check here. But i need to remove the specific migration file. As per my project having 30-40 migration file. I want to remove one of the migration file and its model. Is there any way to do this or have to do it manually.
Upvotes: 5
Views: 12170
Reputation: 39399
Don’t. Migrations are version control for your database. “Removing” a particular migration is like removing a random commit from your Git repository’s history: it can have terrible consequences.
Instead, if you no longer need a table, then create a new migration that drops that table in the up
method, and recreates it in the down
method so the migration can be rolled back.
Upvotes: 2
Reputation: 848
you can increment the batch number of that particular migration to make it latest batch and run rollback command. Rollback one specific migration in Laravel
Upvotes: 0
Reputation: 2154
Just do it manually and save yourself the stress of further issues
...database/migrations
folderphp artisan migrate
, log into your phpmyadmin or SQL(whichever the case is) and in your database, delete the table created by the migrationWorks for me, hope it helps!
Upvotes: 1
Reputation: 1303
Delete the migration file, remove the table from the database, and also remove that file name from migrations
table in the database.
Sometimes, doing things manually is the best way.
Upvotes: 1
Reputation: 175
If you simply remove (delete) the migration file and re-run the migrations (migrate:refresh
), the database tables will be rebuilt (without the table that's defined in the migration file you deleted).
Upvotes: 0