<?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::create('serenata_packages', function (Blueprint $table) {
            $table->id();
            $table->foreignId('organization_id')->constrained('organizations')->cascadeOnDelete();
            $table->string('name', 120);
            $table->string('city', 120)->default('*');
            $table->decimal('base_price', 12, 2)->default(0);
            $table->json('gift_codes')->nullable();
            $table->json('artist_codes')->nullable();
            $table->json('other_cost_codes')->nullable();
            $table->boolean('is_active')->default(true);
            $table->boolean('is_default')->default(false);
            $table->unsignedSmallInteger('sort_order')->default(100);
            $table->timestamps();

            $table->index(['organization_id', 'city', 'is_active'], 'sp_org_city_active_idx');
            $table->index(['organization_id', 'is_default'], 'sp_org_default_idx');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('serenata_packages');
    }
};

