<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('catalog_items', function (Blueprint $table): void {
            $table->enum('ticket_generation_policy', ['per_event_date', 'one_per_unit'])
                ->default('per_event_date')
                ->after('has_tickets');
        });

        DB::table('catalog_items')
            ->where('tenant_code', 'fiesta_futbol_infantil')
            ->update([
                'ticket_generation_policy' => 'one_per_unit',
            ]);
    }

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