<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Pivot enrichi : un exercice positionné dans une routine, avec ses paramètres d'entraînement.
        Schema::create('routine_exercises', function (Blueprint $table) {
            $table->id();
            $table->foreignId('routine_id')->constrained();
            $table->foreignId('exercise_id')->constrained();
            $table->unsignedInteger('position');
            $table->unsignedInteger('sets');
            $table->string('target_reps'); // ex "8-12"
            $table->unsignedInteger('rest_seconds')->nullable();
            $table->string('tempo')->nullable();
            $table->decimal('target_weight', 8, 2)->nullable();
            $table->text('notes')->nullable();
            $table->timestamps();
        });
    }

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