<?php

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

class CreateExercisesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('exercises', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string("name", 100);
            $table->string("slug", 100)->unique()->index();
            $table->longText("description");
            $table->char("modality")->index();
            $table->integer("level")->default(-1)->index();
            $table->string("url_video_predefined", 300);
            $table->timestamps();

        });

        Schema::table('training_workout_lines',function (Blueprint $table){
            $table->foreign("exercise_id")->references("id")->on("exercises")->onDelete("cascade");
            $table->foreign("exercise_scaled_id")->references("id")->on("exercises")->onDelete("cascade");
        });
    }

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