<?php

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

class CreateEventsTable extends Migration
{
    public $set_schema_table = 'eventlogs';
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::create($this->set_schema_table,function($table){
            $table->increments('id');
            $table->integer('user_id')->nullable()->unsigned();
            $table->string('type')->nullable();
            $table->integer('relation_id')->nullable();
            $table->string('content')->nullable();
            $table->integer('comment_id')->nullable()->unsigned();
            $table->foreign('comment_id')->references('id')->on('comments')->onDelete('set null');
            $table->integer('count')->nullable();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::dropIfExists($this->set_schema_table);
    }
}
