HomeLARAVELHow to rollback last migration?

How to rollback last migration?

In Laravel, if you want to rollback the last migration, you can use the Artisan command:

php artisan migrate:rollback

Details:

  • This command reverts the last batch of migrations that were run.
  • If you ran multiple migrations at once, all migrations in the last batch will be rolled back, not just a single migration.

Optional Flags:

  1. Step-wise rollback (rollback only a specific number of migrations):
php artisan migrate:rollback --step=1
  • --step=1 rolls back the last 1 migration.
  • --step=2 rolls back the last 2 migrations, and so on.
  1. Database connection (if using multiple connections):
php artisan migrate:rollback --database=your_connection_name

If you want to rollback all migrations:

php artisan migrate:reset
  • This will undo all migrations in your database.

Share: 

No comments yet! You be the first to comment.

Leave a Reply

Your email address will not be published. Required fields are marked *