DB Migration – To Create a new table

Command:

php artisan make:migration create_user_table --create=user

php artisan migrate

php artisan migrate:rollback

php artisan migrate:reset

php artisan migrate:refresh

php artisan migrate --seed

Migration Class:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateChildAccountTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('member_child', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('parent_id')->comment('主帳號ID');
            $table->tinyInteger('type');
            $table->string('username', 30)->nullable();
            $table->string('child', 20)->default('test');
            $table->longText('description');
            $table->text('description');
            $table->tinyInteger('permission')->comment('1:view, 2:inherit');
            $table->dateTime('login_time')->nullable();
            $table->date('tx_date')->nullable();
            $table->decimal('fee', 10, 2)->nullable()->comment('手續費');
            $table->timestamps();
            //$table->dateTime('created_time');
            //$table->dateTime('updated_time')->nullable();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('member_child');
    }
}

Reference: