Laravel 5.4 Specific Table Migration

Martney Acha picture Martney Acha · Aug 3, 2017 · Viewed 192.4k times · Source

Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations.

Is there a way on how to migrate a certain migration file (1 migration only), cause right now every time there is a change I use php artisan migrate:refresh and all fields are getting reset.

Answer

AddWeb Solution Pvt Ltd picture AddWeb Solution Pvt Ltd · Aug 3, 2017

First you should create one migration file for your table like:

public function up()
    {
        Schema::create('test', function (Blueprint $table) {
            $table->increments('id');
            $table->string('fname',255);
            $table->string('lname',255);
            $table->rememberToken();
            $table->timestamps();
        });
    }

After create test folder in migrations folder then newly created migration moved/copied in test folder and run below command in your terminal/cmd like:

php artisan migrate --path=/database/migrations/test/