<?php

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

class CreateTrainingWorkoutsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('training_workouts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('box_id')->nullable();
            $table->string('name')->nullable();
            $table->longText("description")->nullable();
            $table->string("category")->index();
            $table->timestamps();

            $table->foreign("box_id")->references("id")->on("boxes")->onDelete("cascade"); //si borren un box, borra les entrades amb aquest box

        });

    }

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