<?php

declare(strict_types=1);

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

return new class extends Migration
{
    public function up(): void
    {
        if (Schema::hasColumn('artwork_features', 'force_hero')) {
            return;
        }

        Schema::table('artwork_features', function (Blueprint $table): void {
            $table->boolean('force_hero')->default(false)->after('is_active');
            $table->index(['force_hero', 'is_active'], 'idx_features_force_hero');
        });
    }

    public function down(): void
    {
        if (! Schema::hasColumn('artwork_features', 'force_hero')) {
            return;
        }

        Schema::table('artwork_features', function (Blueprint $table): void {
            $table->dropIndex('idx_features_force_hero');
            $table->dropColumn('force_hero');
        });
    }
};