<?php

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

class AddBookingIdToGuestRegistrationsTable extends Migration
{
    public function up()
    {
        Schema::table('guest_registrations', function (Blueprint $table) {
            $table->unsignedBigInteger('booking_id')->nullable()->after('checkin_id');
            $table->foreign('booking_id')->references('id')->on('bookings')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::table('guest_registrations', function (Blueprint $table) {
            $table->dropForeign(['booking_id']);
            $table->dropColumn('booking_id');
        });
    }
}