<?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('exercises', function (Blueprint $table) {
            $table->id();
            $table->string('name', 150);
            $table->string('name_en', 150)->nullable();

            $table->foreignId('main_muscle_id')->nullable()->constrained('muscles')->nullOnDelete();

            $table->enum('difficulty', ['beginner', 'intermediate', 'advanced'])->default('beginner');

            $table->text('description')->nullable();

            $table->string('gif_path')->nullable();
            $table->string('image_path')->nullable();

            $table->boolean('is_active')->default(true);

            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();

            $table->timestamps();
            $table->softDeletes();

            $table->index('is_active');
            $table->index('difficulty');
        });
    }

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