<?php

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

class CreateColourMatakaWinnersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('colour_mataka_winners', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('result_id')->index();
            $table->unsignedBigInteger('game_id')->index();
            $table->unsignedBigInteger('user_id')->index();
            $table->unsignedBigInteger('bet_id')->index();
            $table->string('bet_place')->index()->nullable();
            $table->double('amount', 8, 2)->index();
            $table->boolean('status')->index()->default(true);
            $table->foreign('result_id')->references('id')->on('colour_mataka_results')->onDelete('cascade');
            $table->foreign('game_id')->references('id')->on('colour_mataka_games')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('bet_id')->references('id')->on('colour_mataka_bettings')->onDelete('cascade');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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