-- CreateEnum
CREATE TYPE "passenger"."ReturnLegStatus" AS ENUM ('NOT_APPLICABLE', 'BOTH_USED', 'OUTBOUND_ONLY', 'INBOUND_ONLY', 'NEITHER_USED');

-- AlterTable: add return leg tracking columns to Booking
ALTER TABLE "passenger"."Booking"
  ADD COLUMN "returnLegStatus" "passenger"."ReturnLegStatus" NOT NULL DEFAULT 'NOT_APPLICABLE',
  ADD COLUMN "outboundBoardedAt" TIMESTAMP(3),
  ADD COLUMN "returnBoardedAt"   TIMESTAMP(3);

-- Set NEITHER_USED for existing confirmed round-trip bookings
UPDATE "passenger"."Booking"
SET "returnLegStatus" = 'NEITHER_USED'
WHERE "bookingType" = 'ROUND_TRIP'
  AND "status" IN ('CONFIRMED', 'COMPLETED');

-- AlterTable: add leg column to GateValidationLog
ALTER TABLE "passenger"."GateValidationLog"
  ADD COLUMN "leg" TEXT;
