<?php

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

class CreateNewUserWinnersAmountTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('new_user_winners_amount', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->index();
            $table->unsignedBigInteger('stores_id')->index();
            $table->unsignedBigInteger('game_group_id')->index();
            $table->unsignedBigInteger('game_id')->index();
            $table->unsignedBigInteger('day_id')->index();
            $table->unsignedBigInteger('game_winners_id')->index();
            $table->string('open_time')->index();
            $table->string('close_time')->index()->nullable();
            $table->string('panna_name')->index()->nullable();
            $table->double('amount',8,2)->index();
            $table->boolean('status')->index()->default(true);
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('stores_id')->references('id')->on('new_store')->onDelete('cascade');
            $table->foreign('game_group_id')->references('id')->on('game_group')->onDelete('cascade');
            $table->foreign('game_id')->references('id')->on('game')->onDelete('cascade');
            $table->foreign('day_id')->references('id')->on('days')->onDelete('cascade');
            $table->foreign('game_winners_id')->references('id')->on('new_game_winners')->onDelete('cascade');
        });
    }

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