<?php

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

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

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