<?php

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

return new class extends Migration
{
    public function up(): void
    {
        DB::table('catalog_items')
            ->where('tenant_code', 'fiesta_futbol_infantil')
            ->update(['has_tickets' => true]);
    }

    public function down(): void
    {
        $entryCategoryIds = DB::table('categorias')
            ->select('id')
            ->where('tenant_code', 'fiesta_futbol_infantil')
            ->where('nombre', 'Entradas');

        DB::table('catalog_items')
            ->where('tenant_code', 'fiesta_futbol_infantil')
            ->whereNotIn('category_id', $entryCategoryIds)
            ->update(['has_tickets' => false]);
    }
};
