<?php

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

class CreateCommentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('comments', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('model_id');
            $table->string('model_type');
            $table->unsignedInteger('member_id')->nullable();
            $table->char('lang', 10)->index();
            $table->string('name')->nullable()->comment('名称或会员名');
            $table->string('contact')->nullable();
            $table->text('content');
            $table->string('ip');
            $table->unsignedTinyInteger('is_display')->default(1);
            $table->timestamps();

            $table->index(['model_id', 'model_type'], 'i_model_lang_index');
        });
    }

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