-- AlterTable
ALTER TABLE "flights" ADD COLUMN     "aircraftType" TEXT,
ADD COLUMN     "airlineIata" TEXT,
ADD COLUMN     "airlineName" TEXT,
ADD COLUMN     "arrivalBaggage" TEXT,
ADD COLUMN     "arrivalDelay" INTEGER,
ADD COLUMN     "arrivalGate" TEXT,
ADD COLUMN     "arrivalTerminal" TEXT,
ADD COLUMN     "autoTrackEnabled" BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN     "departureDelay" INTEGER,
ADD COLUMN     "departureGate" TEXT,
ADD COLUMN     "departureTerminal" TEXT,
ADD COLUMN     "estimatedArrival" TIMESTAMP(3),
ADD COLUMN     "estimatedDeparture" TIMESTAMP(3),
ADD COLUMN     "lastApiResponse" JSONB,
ADD COLUMN     "lastPolledAt" TIMESTAMP(3),
ADD COLUMN     "liveAltitude" DOUBLE PRECISION,
ADD COLUMN     "liveDirection" DOUBLE PRECISION,
ADD COLUMN     "liveIsGround" BOOLEAN,
ADD COLUMN     "liveLatitude" DOUBLE PRECISION,
ADD COLUMN     "liveLongitude" DOUBLE PRECISION,
ADD COLUMN     "liveSpeed" DOUBLE PRECISION,
ADD COLUMN     "liveUpdatedAt" TIMESTAMP(3),
ADD COLUMN     "pollCount" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN     "trackingPhase" TEXT NOT NULL DEFAULT 'FAR_OUT';

-- CreateTable
CREATE TABLE "flight_api_budget" (
    "id" TEXT NOT NULL,
    "monthYear" TEXT NOT NULL,
    "requestsUsed" INTEGER NOT NULL DEFAULT 0,
    "requestLimit" INTEGER NOT NULL DEFAULT 100,
    "lastRequestAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "flight_api_budget_monthYear_key" ON "flight_api_budget"("monthYear");

-- CreateIndex
CREATE INDEX "flights_trackingPhase_idx" ON "flights"("trackingPhase");

-- CreateIndex
CREATE INDEX "flights_scheduledDeparture_idx" ON "flights"("scheduledDeparture");
