<?php

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

class CreateCustomResultsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('custom_results', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->index()->nullable();
            $table->unsignedBigInteger('game_id')->index()->nullable();
            $table->unsignedBigInteger('play_time_id')->index()->nullable();
            $table->unsignedBigInteger('color_result_condition_id')->index()->nullable();
            $table->unsignedBigInteger('roulettte_result_condition_id')->index()->nullable();
            $table->string('period')->index();
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('game_id')->references('id')->on('roullete_games')->onDelete('cascade');
            $table->foreign('play_time_id')->references('id')->on('game_play_times')->onDelete('cascade');
            $table->foreign('color_result_condition_id')->references('id')->on('result_conditions')->onDelete('cascade');
            $table->foreign('roulettte_result_condition_id')->references('id')->on('roullet_result_conditions')->onDelete('cascade');
        });
    }

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