Javatpoint Logo
Javatpoint Logo

Laravel Migration Commands

In this topic, we will learn about the migration commands. To view the migration commands, open the Git bash window, and enter the command "php artisan list". This command lists all the commands available in Laravel.

Laravel Migration Commands

In the above output, the highlighted area is the list of all the migrate commands. There are six commands of migrate in Laravel:

  • migrate:fresh
  • migrate:install
  • migrate:refresh
  • migrate:reset
  • migrate:rollback
  • migrate:status

Migration commands

migrate:fresh

The migrate:fresh command is used to drop all the tables from the database, and then it re-runs all the migrations.

Syntax of migrate:fresh command:

php artisan migrate:fresh

Laravel Migration Commands

The above output shows that the fresh command drops all the tables and then re-migrate it.

migrate:install

The migrate:install command creates the migration table in a database.

Syntax of migrate:install command:

php artisan migrate:install

Laravel Migration Commands

The above output shows that the install command creates the new migration table.

migrate:refresh

The migrate:refresh command is used to rollback all the migrations and then re-run the migrations. Basically, it is used to re-create the entire database.

Syntax of migrate:refresh command:

php artisan migrate:refresh

Laravel Migration Commands

The above output shows that the refresh command rollbacks all the migrations and then re-migrate all the migrations.

migrate:reset

The migrate:reset command is used to rollback all the migrations, i.e., it drops all the tables that you have created in your database.

Syntax of migrate:reset command:

php artisan migrate:reset

Laravel Migration Commands

The above output shows that reset command rollbacks all the migrations.

migrate:rollback

The migrate:rollback is used to rollback the last database migration.

Laravel Migration Commands

migrate:status

The migrate:status command is used to show the status of each migration.

Syntax of migrate:status command:

php artisan migrate:status

Laravel Migration Commands
Next TopicLaravel database




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA