<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('set_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('workout_session_id')->constrained();
            $table->foreignId('exercise_id')->constrained();
            $table->unsignedInteger('set_number');
            $table->unsignedInteger('reps')->nullable();
            $table->decimal('weight', 8, 2)->nullable();
            $table->decimal('rpe', 3, 1)->nullable();                    // Rate of Perceived Exertion (0-10)
            $table->unsignedInteger('duration_seconds')->nullable();     // séries cardio/isométriques
            $table->decimal('distance_meters', 8, 2)->nullable();        // séries cardio (course, rameur...)
            $table->boolean('is_warmup')->default(false);
            $table->boolean('is_completed')->default(true);
            $table->dateTime('logged_at');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('set_logs');
    }
};
