<?php

use App\Models\WorkoutCategory;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('workout_categories', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
        });

        Schema::create('workout_category_translations', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(WorkoutCategory::class)->constrained()->cascadeOnDelete();
            $table->string('title');
            $table->string('locale')->index();
            $table->unique(['workout_category_id', 'locale']);
        });
    }

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