<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Creates the self_paced_categories table for organising self-paced courses
     * into named categories with icons and display ordering.
     */
    public function up(): void
    {
        Schema::create('self_paced_categories', function (Blueprint $table) {
            $table->id();

            $table->string('name', 191);
            $table->string('slug', 191)->unique();
            $table->text('description')->nullable();
            $table->string('icon', 100)->nullable();
            $table->string('color', 20)->nullable();
            $table->integer('sort_order')->default(0);

            $table->timestamps();

            $table->index('slug');
            $table->index('sort_order');
        });
    }

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