<?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('artworks', function (Blueprint $table): void {
            if (! Schema::hasColumn('artworks', 'is_mature')) {
                $table->boolean('is_mature')->default(false)->after('is_approved')->index();
            }
        });
    }

    public function down(): void
    {
        Schema::table('artworks', function (Blueprint $table): void {
            if (Schema::hasColumn('artworks', 'is_mature')) {
                $table->dropIndex(['is_mature']);
                $table->dropColumn('is_mature');
            }
        });
    }
};