-- CreateTable
CREATE TABLE "Journey" (
    "id" TEXT NOT NULL,
    "passengerId" TEXT NOT NULL,
    "status" TEXT NOT NULL,
    "totalMinor" INTEGER NOT NULL,
    "currency" TEXT NOT NULL DEFAULT 'ETB',
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "JourneySegment" (
    "id" TEXT NOT NULL,
    "journeyId" TEXT NOT NULL,
    "tripId" TEXT NOT NULL,
    "segmentOrder" INTEGER NOT NULL,
    "seatId" TEXT,
    "coachId" TEXT,
    "departureStationId" TEXT NOT NULL,
    "arrivalStationId" TEXT NOT NULL,

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

-- AddForeignKey
ALTER TABLE "JourneySegment" ADD CONSTRAINT "JourneySegment_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "JourneySegment" ADD CONSTRAINT "JourneySegment_tripId_fkey" FOREIGN KEY ("tripId") REFERENCES "Trip"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
