PASSWORD RESET

Your destination for complete Tech news

PHP

How to rollback one specific migration in laravel?

400 0
< 1 min read

In Laravel, you can use the migrate:rollback Artisan command to rollback the last migration. To rollback a specific migration, you can pass the --step option to the command, followed by the number of migrations to rollback.

For example, to rollback the last 2 migrations, you can run the following command:

php artisan migrate:rollback --step=2

If you want to rollback a specific migration, you can use the migrate:reset command, which rolls back all migrations and then re-runs them. You can pass the --pretend option to the command to see which migrations will be rolled back and re-run, without actually executing the changes.

For example, to rollback and re-run the last 2 migrations, you can run the following command:

php artisan migrate:reset --pretend

This will show you the list of migrations that will be rolled back and re-run. If you want to actually execute the changes, you can remove the --pretend option.

Note that rolling back and re-running migrations can have unintended consequences, such as data loss or duplication. It is recommended to carefully consider the impact of these actions before executing them.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.