<?php

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

class CreateQuestionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('questions', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->collation = 'utf8_unicode_ci';
            $table->charset = 'utf8'; 
            $table->bigIncrements('question_id')->comment('问题ID');
            $table->string('title')->comment('问题标题');
            $table->unsignedTinyInteger('is_released')->comment('是否发布');
            $table->dateTime('created_at')->useCurrent()->comment('创建时间');
            $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
            $table->dateTime('deleted_at')->comment('删除时间');
        });

        Schema::create('options', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->collation = 'utf8_unicode_ci';
            $table->charset = 'utf8'; 
            $table->bigIncrements('option_id')->comment('选项ID');
            $table->string('title')->comment('选项标题');
            $table->unsignedBigInteger('question_id')->unsigned()->comment('问题ID');
            $table->unsignedTinyInteger('is_answer')->comment('是否答案');
            $table->dateTime('created_at')->useCurrent()->comment('创建时间');
            $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
            $table->dateTime('deleted_at')->comment('删除时间');
        });
    }

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