<?php

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

class CreateChakriResultsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chakri_results', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('period_id')->index();
            $table->unsignedBigInteger('game_id')->index();
            $table->string('bet_place')->index()->nullable();
            $table->double('admin_amount',8,2)->index();
            $table->double('total_bet_amount',8,2)->index();
            $table->double('distributed_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->timestamps();
            $table->softDeletes();
        });
    }

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