<?php

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

class CreateUserOrdersTable extends Migration
{

    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('user_orders', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('identity_id');
            $table->decimal('price');
            $table->tinyInteger('year')->default(1)->comment('开通年限');
            $table->string('state');
            $table->string('name')->comment('姓名');
            $table->string('card_no')->comment('银行卡号');
            $table->string('cover')->comment('凭证');
            $table->tinyInteger('type')->comment('1 开通 2 续费');
            $table->tinyInteger('channel')->default(1)->comment('1 身份 2 体验官');
            $table->timestamps();
            $table->index(['user_id', 'identity_id']);
        });
    }

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

}
