<?php

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

class CreateCalendarGamesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('calendar_games', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('calendar_id')->unsigned()->nullable();
            $table->foreign('calendar_id')->references('id')->on('calendars');
            $table->integer('home_team_id')->unsigned()->nullable();
            $table->foreign('home_team_id')->references('id')->on('teams');
            $table->integer('away_team_id')->unsigned()->nullable();
            $table->foreign('away_team_id')->references('id')->on('teams');
            $table->datetime('date');
            $table->integer('day');
            $table->string('type');
            $table->integer('home_goals')->nullable();
            $table->integer('away_goals')->nullable();
            $table->integer('home_points')->nullable();
            $table->integer('away_points')->nullable();
            $table->timestamps();
        });
    }

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