<?php

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

class CreateRegionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('regions', function (Blueprint $table) {
            $table->integer('id')->comment('编号');
            $table->integer('code')->comment('地区代码');
            $table->integer('parent_code')->comment('父级');
            $table->tinyInteger('type')->comment('类型：1省，2市，3区');
            $table->string('name', 32)->comment('名称');
            $table->string('full_name', 32)->comment('全名');

            //$table->index('code', 'parent_code', 'type');
            $table->index('code', 'parent_code');
        });
    }

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