-- Add contact fields to Booking table
ALTER TABLE "passenger"."Booking" 
ADD COLUMN "contactEmail" TEXT,
ADD COLUMN "contactPhone" TEXT;

-- Create SavedPassengerProfile table
CREATE TABLE "passenger"."SavedPassengerProfile" (
    "id" TEXT NOT NULL,
    "userId" TEXT,
    "deviceId" TEXT,
    "passengerName" TEXT NOT NULL,
    "dateOfBirth" TIMESTAMP(3) NOT NULL,
    "idDocumentType" "passenger"."IdDocumentType" NOT NULL,
    "passportNumber" TEXT,
    "passportCountry" TEXT,
    "nationality" TEXT,
    "phone" TEXT,
    "email" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "SavedPassengerProfile_pkey" PRIMARY KEY ("id")
);

-- Create indexes
CREATE INDEX "SavedPassengerProfile_userId_idx" ON "passenger"."SavedPassengerProfile"("userId");
CREATE INDEX "SavedPassengerProfile_deviceId_idx" ON "passenger"."SavedPassengerProfile"("deviceId");

-- Add comment
COMMENT ON TABLE "passenger"."SavedPassengerProfile" IS 'Stores passenger details for quick rebooking (by userId or deviceId)';
