Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


What are the most used artisan commands for migration in Laravel?

Chinweuba Elijah Azubuike


In this shot, we wil go over the most used artisan commands for migration in Laravel.


  • php artisan make:migration table_name creates a schema for the table. We can edit the schema to suit the needs of our application.

Note: make:migration tries to guess the name of the table, so ensure that the table_name represents what you want to name the table.

  • make:migration creates a database migration.

  • php artisan migrate publishes all our schema to the database. This command also creates the table in the database.

  • php artisan migrate:status checks the status of the migration.

  • migrate:status checks the migrations we have run.

  • php artisan migrate --force publishes schema to the database, even in production. migrate --force ensures that the migrations are published even when the application is in product mode.

  • php artisan migrate:rollback reverses the last migration batch.

Note: Only the latest migration is rolled back, rather than all the migrations. That might involve more than one file.

  • php artisan migrate:reset reverses all migration, unlike :rollback.

  • php artisan migrate:fresh is used when we want a fresh or new installation of our database. It deletes all the existing tables of the database and runs the migrate command.

  • php artisan migrate:refresh is a two in one command that executes the :rollback command and the migrate command.

In this instance, the migrate:rollback is done on all the migrations. It is very similar to the migrate:fresh.

  • php artisan migrate:fresh --seed executes the migrate:fresh command, but then it seeds the database. We can use this command when we install the application on a new host, so that it seeds (i.e., inserts data) into the database.

These are the most used artisan commands we should have at our fingertips while doing anything related to database migration.




Chinweuba Elijah Azubuike

View all Courses

Keep Exploring