<?php

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

class CreateEventOrder extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('event_order', function (Blueprint $table) {

            $table->increments('id');
            $table->timestamps();

            /** 20170101+121210+00000000 */
            $table->string('sn', 30)->nullable()->comment('订单号');

            $table->integer('memberUserId')->comment('用户ID')->nullable();
            $table->integer('eventId')->comment('课程ID')->nullable();

            /** @see \App\Types\EventOrderStatus */
            $table->tinyInteger('status')->comment('正在报名')->nullable();

            $table->decimal('totalFee', 20, 2)->nullable()->comment('总价格');
            $table->decimal('payFee', 20, 2)->nullable()->comment('支付价格');

            $table->timestamp('payTime')->nullable()->comment('支付时间');

            $table->text('applyInfo')->comment('报名需要填写的字段')->nullable();

            $table->unique(['sn']);
            $table->index(['memberUserId']);
            $table->index(['eventId', 'status']);


        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
    }
}
