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.

  • 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

migrate:install

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

Syntax of migrate:install command:

php artisan migrate:install

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

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

migrate:rollback

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

migrate:status

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

Syntax of migrate:status command:

php artisan migrate:status

Additional Reading

Dheeraj Pal:

This website uses cookies.