<?php

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

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

        Schema::create('virtual_company_accounts', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
            $table->string('nickname', 32)->default('')->comment('昵称');
            $table->string('mobile', 20)->nullable()->comment('手机号');
            $table->string('username', 32)->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->timestamps();
            $table->softDeletes();

            $table->unique(['mobile', 'deleted_at']);
            $table->comment('VD企业账号表');
        });
    }

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