<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('reservations', function (Blueprint $table) {
            $table->foreignId('lodging_id')->nullable()->constrained('lodgings')->nullOnDelete();
            $table->dropColumn(['lodging_type', 'lodging_number']);
        });
    }

    public function down(): void
    {
        Schema::table('reservations', function (Blueprint $table) {
            $table->dropForeign(['lodging_id']);
            $table->dropColumn('lodging_id');
            $table->string('lodging_type')->default('cabana');
            $table->integer('lodging_number')->default(1);
        });
    }
};
