<?php

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

class CreateCalendarTemplatesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('calendar_templates', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('box_id')->nullable();
            $table->integer('default_duration');
            $table->integer('time_between_wods');
            $table->time('start_day_time')->index();
            $table->time('end_day_time')->index();
            $table->string('days',20);
            $table->timestamps();

            $table->foreign('box_id')->references('id')->on('boxes')->onDelete('cascade');
        });
    }

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