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:
- Step-wise rollback (rollback only a specific number of migrations):
php artisan migrate:rollback --step=1
--step=1rolls back the last 1 migration.--step=2rolls back the last 2 migrations, and so on.
- 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.
