<?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('package_bookings', function (Blueprint $table) {
            // Drop foreign key constraint before dropping the column
            $table->dropForeign(['user_id']);

            // Now drop the column
            $table->dropColumn('user_id');

            // Add customer_id column
            $table->unsignedBigInteger('customer_id')->after('id')->nullable();
        });
    }

    public function down(): void
    {
        Schema::table('package_bookings', function (Blueprint $table) {
            // Drop customer_id column
            $table->dropColumn('customer_id');

            // Re-add user_id column
            $table->unsignedBigInteger('user_id')->nullable()->after('id');

            // (Optional) Add back foreign key if needed
            // $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }
};
