<?php

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

class CreateUserIdentitiesTable extends Migration
{

    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('user_identities', function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('身份名称');
            $table->string('cover')->nullable()->comment('身份的LOGO');
            $table->string('description')->nullable()->comment('简介');
            $table->integer('stock')->default(0)->comment('水的库存');
            $table->unsignedInteger('order')->default(0)->comment('展示排序');
            $table->json('conditions')->nullable()->comment('升级的条件，JSON');
            $table->json('rules')->nullable()->comment('身份权益，JSON');
            $table->json('rights')->nullable()->comment('前台显示的权益');
            $table->json('ruleshows')->nullable()->comment('前台显示的权益');
            $table->tinyInteger('can_buy')->default(0)->comment('是否可以前台购买');
            $table->tinyInteger('years')->default(0)->comment('有效期（年）');
            $table->boolean('status')->default(0);
            $table->boolean('serial_open')->default(0)->comment('是否开启身份编号');
            $table->unsignedInteger('serial_places')->default(0)->comment('身份编号位数');
            $table->string('serial_prefix', 4)->nullable()->comment('身份编号前缀');
            $table->string('protocol_url')->nullable()->comment('协议地址');
            $table->boolean('default')->default(0)->comment('是否默认身份');
            $table->tinyInteger('channel')->default(1)->comment('缴费渠道');
            $table->integer('total')->default(0)->comment('可开通总数');
            $table->tinyInteger('job')->default(0)->comment('职位');
            $table->timestamp('end_at')->nullable()->comment('结束时间');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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

}
