Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon What is the difference between migrate:refresh and migrate:reset in Laravel
    Laravel migrate:refresh migrate:reset database migration Laravel migration commands Laravel development


What is the difference between migrate:refresh and migrate:reset in Laravel


The main difference between `migrate:refresh` and `migrate:reset` in Laravel is:

1. migrate:refresh:
- The `migrate:refresh` command will rollback all of your migrations and then run the `migrate` command.
- This effectively resets your entire database, including all tables and data.
- After running `migrate:refresh`, your database will be in a completely fresh state, as if you had just installed your application for the first time.
- The `migrate:refresh` command is useful when you need to completely reset your database, for example, during development or testing.

2. migrate:reset:
- The `migrate:reset` command will only rollback all of your migrations, without running the `migrate` command afterwards.
- This means that it will remove all of the tables and data from your database, but it won't re-create the tables.
- The `migrate:reset` command is useful when you need to remove all of the database changes made by your migrations, but you don't necessarily want to start from a completely fresh database state.

In summary:

- `migrate:refresh` will rollback all migrations and then re-run them, effectively resetting your entire database.
- `migrate:reset` will only rollback all migrations, without re-running them, leaving your database in an empty state.

The choice between `migrate:refresh` and `migrate:reset` depends on your specific use case. If you need to completely reset your database, `migrate:refresh` is the better option. If you only need to remove the changes made by your migrations, `migrate:reset` is more appropriate.

Citations:
[1] https://www.javatpoint.com/laravel-migration-commands
[2] https://www.javatpoint.com/laravel-migration
[3] https://laravel.com/docs/5.0/migrations
[4] https://dev.to/techtoolindia/how-to-create-migration-in-laravel--2532
[5] https://laravel.com/docs/5.2/migrations