<?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::table('bookings', function (Blueprint $table): void {
            $table->string('rate_name')->nullable()->after('booking_variant');
            $table->unsignedInteger('min_nights_applied')->default(1)->after('nights');
            $table->boolean('discount_applied')->default(false)->after('breakfast');
            $table->string('pricing_mode')->default('calendar')->after('discount_applied');
            $table->boolean('manual_price_override')->default(false)->after('pricing_mode');
            $table->json('rate_snapshot_json')->nullable()->after('manual_price_override');
            $table->timestamp('price_calculated_at')->nullable()->after('rate_snapshot_json');
        });
    }

    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table): void {
            $table->dropColumn([
                'rate_name',
                'min_nights_applied',
                'discount_applied',
                'pricing_mode',
                'manual_price_override',
                'rate_snapshot_json',
                'price_calculated_at',
            ]);
        });
    }
};
