<?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('bookings', function (Blueprint $table) {
            // Set only when one submission creates more than one booking
            // (multi-vehicle dispatch, e.g. 2 Saloons + 1 Estate for the same
            // trip) so the jobs table/edit page can link the sibling rows.
            $table->string('group_id')->nullable()->after('booking_number')->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropColumn('group_id');
        });
    }
};
