-- CreateTable
CREATE TABLE "AircraftLocation" (
    "id" TEXT NOT NULL,
    "aircraftId" TEXT NOT NULL,
    "latitude" DOUBLE PRECISION NOT NULL,
    "longitude" DOUBLE PRECISION NOT NULL,
    "altitude" DOUBLE PRECISION NOT NULL,
    "speed" DOUBLE PRECISION NOT NULL,
    "heading" DOUBLE PRECISION NOT NULL,
    "timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "AircraftLocation_aircraftId_idx" ON "AircraftLocation"("aircraftId");

-- CreateIndex
CREATE INDEX "AircraftLocation_timestamp_idx" ON "AircraftLocation"("timestamp");

-- AddForeignKey
ALTER TABLE "AircraftLocation" ADD CONSTRAINT "AircraftLocation_aircraftId_fkey" FOREIGN KEY ("aircraftId") REFERENCES "Aircraft"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
