How to Create Migration in Laravel 6 using Command

Admin   Laravel   321  2021-03-17 06:40:04

Hi Guys,

Today, we will learn to create migrations using Artisan . It will create a database table we will take help of make:migration.

A migration class contains two methods: up and down. The up method is used to add new tables, columns, or indexes to your database,the down method should reverse the operations performed by the up method.

Example 1

  php artisan make:migration create_demos_table

-> This command is used to create migration table in your project.

->It will create in database folder in migration folder.




use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

class CreateDemosTable extends Migration



* Run the migrations.


* @return void


public function up()


Schema::create('table', function (Blueprint $table) {










* Reverse the migrations.


* @return void


public function down()





Create migration after use bellow command to migrate your table.

  php artisan migrate 

Example 2

  php artisan migrate:status

->Above command is used for table creation then after you can migrate or not.

->It will show List of table migration with migrate or not.

Example 3

  php artisan make:migration create_demos_table --create=demos

->This command is used to create table migration in your project.

->It will help you create migration your table.

Example 4

  php artisan migrate:rollback

->To rollback the latest migration operation, you may use the rollback command

->This command is used to edit your table migration.

->--step=5 : It will rollback the last five migrations.

Example 5

  php artisan migrate:refresh

-> This command is used to truncate your database table.

->--step=5 : It will truncate your last five database table.

Example 6

   php artisan make:migration create_demos_table --table=demos

->The above command is used to create table migration.

->File created in your project.

Example 7.


->This command is used to the location where the migration file should be created.

Example 8.

   php artisan make:migration create_demos_table --fullpath

->This command is used output the full path of the migration.

It will help you...