<?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::table('spa_courses', function (Blueprint $table) {
            $table
                ->string('category', 20)
                ->default('body')
                ->comment('分類：face/body')
                ->after('slug');

            $table->index(['category', 'sort_order']);
        });
    }

    public function down(): void
    {
        Schema::table('spa_courses', function (Blueprint $table) {
            $table->dropIndex(['category', 'sort_order']);
            $table->dropColumn('category');
        });
    }
};
