php artisan migrate command in Laravel


The 'php artisan migrate' command lets you run the database migration on your application, but there is more than that, there are other variant of this command that you can use such as rollback, reset, refresh, status, install and so on.

Besides the standard 'php artisan migrate' command, you probably already know about 'php artisan migrate:rollback', but what about reset, refresh and some other commands? let's find out.

What's the different between migrate:rollback and migrate:reset?
The 'php artisan migrate:rollback' allows you to rollback the last migration, which means only one migration, but if you want to rollback all database migration on your application, use the 'php artisan migrate:reset' instead.

So that's the different between 'rollback' and 'reset', the 'rollback' will return to previous migration meaning only one migration is rollback, while 'reset' will rollback to the beginning of your migration meaning all migration will be rollback.

Another cool migration command is the 'php artisan migrate:refresh', what this command does is reset all the migration (rollback all migration) and then run the migration again.

The four commands (migrate, migrate:rollback, migrate:reset, and migrate:refresh) are available on both laravel 4 and laravel 5. There some commands that are specific for laravel 4 and others only available on laravel 5, here's the list of commands on both laravel 4 and 5:

Laravel 4 migration command:
CommandDescription
php artisan migrateRun the database migrations
php artisan migrate:installCreate the migration repository
php artisan migrate:makeCreate a new migration file
php artisan migrate:publishPublish a package's migrations to the application
php artisan migrate:refreshReset and re-run all migrations
php artisan migrate:resetRollback all database migrations
php artisan migrate:rollbackRollback the last database migration


Laravel 5 migration command:
CommandDescription
php artisan migrateRun the database migrations
php artisan migrate:installCreate the migration repository
php artisan migrate:refreshReset and re-run all migrations
php artisan migrate:resetRollback all database migrations
php artisan migrate:rollbackRollback the last database migration
php artisan migrate:statusShow the status of each migration
Latest


EmoticonEmoticon