<?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
    {
        if (! Schema::hasColumn('catalog_items', 'event_product_type')) {
            return;
        }

        Schema::table('catalog_items', function (Blueprint $table): void {
            $table->dropColumn('event_product_type');
        });
    }

    public function down(): void
    {
        if (Schema::hasColumn('catalog_items', 'event_product_type')) {
            return;
        }

        Schema::table('catalog_items', function (Blueprint $table): void {
            $table->enum('event_product_type', ['entrada', 'producto'])
                ->nullable()
                ->after('tenant_code');
        });
    }
};
