id(); $table->string('tenant_codigo'); $table->unsignedBigInteger('event_id')->nullable(); $table->softDeletes(); }); Schema::create('tenants', function (Blueprint $table): void { $table->id(); $table->string('codigo')->unique(); $table->unsignedBigInteger('active_event_id')->nullable(); }); Schema::create('catalog_items', function (Blueprint $table): void { $table->id(); $table->string('tenant_code'); $table->string('slug'); $table->string('nombre')->default('Entrada'); $table->string('type')->default('standard'); $table->unsignedBigInteger('inventory_id')->nullable(); $table->string('inventory_policy'); $table->decimal('precio', 10, 2); $table->timestamp('sales_end_at')->nullable(); $table->softDeletes(); $table->boolean('has_tickets')->default(true); $table->unsignedBigInteger('event_id')->nullable(); }); Schema::create('inventories', function (Blueprint $table): void { $table->id(); foreach (['real_stock', 'reserved_stock', 'sold_units', 'refunded_units'] as $column) { $table->integer($column)->default(0); } }); Schema::create('variantes', function (Blueprint $table): void { $table->id(); $table->foreignId('catalog_item_id'); $table->foreignId('inventory_id'); $table->decimal('precio', 10, 2); $table->unsignedBigInteger('event_date_id')->nullable(); $table->unsignedBigInteger('replaced_by_variant_id')->nullable(); $table->timestamp('sales_disabled_at')->nullable(); $table->softDeletes(); }); Schema::create('event_dates', function (Blueprint $table): void { $table->id(); $table->date('date'); $table->time('time_start')->nullable(); $table->unsignedBigInteger('rescheduled_to_event_date_id')->nullable(); $table->timestamp('suspended_at')->nullable(); }); Schema::create('attribute', function (Blueprint $table): void { $table->id(); $table->string('codigo'); $table->string('type')->default('string'); }); Schema::create('item_attributes', function (Blueprint $table): void { $table->id(); $table->foreignId('catalog_item_id'); $table->foreignId('attribute_id'); $table->boolean('allow_multi_select')->default(false); $table->integer('sort_order')->default(0); }); Schema::create('attribute_options', function (Blueprint $table): void { $table->id(); $table->foreignId('attribute_id'); $table->string('value'); $table->string('label'); $table->integer('sort_order')->default(0); }); Schema::create('variant_values', function (Blueprint $table): void { $table->id(); $table->foreignId('variant_id'); $table->foreignId('item_attribute_id'); $table->string('value'); }); Schema::create('variant_event_dates', function (Blueprint $table): void { $table->foreignId('variant_id'); $table->foreignId('event_date_id'); }); Schema::create('tickets', function (Blueprint $table): void { $table->id(); $table->foreignId('user_id'); $table->foreignId('source_variant_id')->nullable(); $table->string('tenant_code')->nullable(); $table->uuid('ticket')->nullable()->unique(); $table->unsignedBigInteger('source_catalog_item_id')->nullable(); $table->unsignedBigInteger('source_purchase_item_id')->nullable(); $table->unsignedBigInteger('event_id')->nullable(); $table->timestamp('used_at')->nullable(); $table->timestamp('disabled_at')->nullable(); $table->timestamp('cancelled_at')->nullable(); $table->timestamp('refunded_at')->nullable(); }); Schema::create('value_changes', function (Blueprint $table): void { $table->id(); $table->morphs('trackable'); $table->string('tenant_code'); $table->string('attribute'); $table->text('old_value')->nullable(); $table->text('new_value')->nullable(); $table->timestamp('changed_at'); $table->string('actor_type'); $table->foreignId('user_id')->nullable(); }); (require database_path('migrations/2026_09_23_010000_create_desfile_entry_reservations_table.php'))->up(); (require database_path('migrations/2026_09_24_000000_add_administrative_entry_reservation_stock.php'))->up(); (require database_path('migrations/2026_09_24_010000_add_soft_deletes_to_desfile_entry_reservations_table.php'))->up(); (require database_path('migrations/2026_10_02_000000_generalize_ticket_reservations.php'))->up(); DB::table('tenants')->insert(['codigo' => $tenantCode]); DB::table('users')->insert(['id' => 1, 'tenant_codigo' => $tenantCode]); DB::table('catalog_items')->insert([ 'id' => 1, 'tenant_code' => $tenantCode, 'slug' => 'entrada', 'inventory_policy' => 'tracked', 'precio' => 100, ]); foreach ([1, 2] as $id) { DB::table('inventories')->insert(['id' => $id, 'real_stock' => 3]); DB::table('variantes')->insert(['id' => $id, 'catalog_item_id' => 1, 'inventory_id' => $id, 'precio' => 250]); } DB::table('tenants')->insert(['codigo' => 'other']); DB::table('users')->insert(['id' => 2, 'tenant_codigo' => 'other']); DB::table('inventories')->insert(['id' => 3, 'real_stock' => 3]); DB::table('catalog_items')->insert([ ['id' => 2, 'tenant_code' => $tenantCode, 'slug' => 'general', 'inventory_policy' => 'tracked', 'inventory_id' => 3, 'precio' => 700], ['id' => 3, 'tenant_code' => 'other', 'slug' => 'other', 'inventory_policy' => 'unlimited', 'inventory_id' => null, 'precio' => 900], ['id' => 4, 'tenant_code' => $tenantCode, 'slug' => 'unlimited', 'inventory_policy' => 'unlimited', 'inventory_id' => null, 'precio' => 500], ]); foreach (['tipo' => 'NORMAL', 'sector' => 'A', 'fila' => '3', 'asiento' => '17'] as $code => $value) { $attributeId = DB::table('attribute')->insertGetId(['codigo' => $code]); $itemAttributeId = DB::table('item_attributes')->insertGetId([ 'catalog_item_id' => 1, 'attribute_id' => $attributeId, ]); DB::table('attribute_options')->insert([ 'attribute_id' => $attributeId, 'value' => $value, 'label' => $value, ]); foreach ([1, 2] as $variantId) { DB::table('variant_values')->insert([ 'variant_id' => $variantId, 'item_attribute_id' => $itemAttributeId, 'value' => $value, ]); } } } }