<?php

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

class CreateAccountsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('accounts')) {
            return;
        }

        Schema::create('accounts', function (Blueprint $table) {
            $table->increments('id')->comment('账户ID');
            $table->string('username', 32)->default('')->comment('登录名');
            $table->string('nickname', 32)->default('')->comment('昵称');
            $table->string('email', 32)->default('')->comment('邮箱');
            $table->string('mobile', 16)->default('')->comment('手机号');
            $table->string('password', 32)->default('')->comment('密码');
            $table->string('salt', 6)->default('')->comment('盐');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0未激活 1正常 2禁用');
            $table->nestedset();
            $table->timestamps();
            $table->softDeletes();
            
            $table->index('username');
            $table->index('mobile');

            $table->comment('平台账号');
            $table->setIncrement(100000);
        });
    }

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