-- Locator receiver telemetry + device identity by serial number.
-- NOTE: hand-edited — Prisma's diff wanted to drop the geom GIST index and the
-- generated-column expression on locate_points.geom; those statements were removed.

-- CreateEnum
CREATE TYPE "LocateMode" AS ENUM ('PEAK', 'NULL', 'BROAD_PEAK', 'SONDE');

-- AlterTable
ALTER TABLE "devices" ALTER COLUMN "mqttUsername" DROP NOT NULL;

-- AlterTable
ALTER TABLE "locate_points" ADD COLUMN     "compassDeg" DECIMAL(5,2),
ADD COLUMN     "currentMa" DECIMAL(9,3),
ADD COLUMN     "distortionPct" DECIMAL(5,2),
ADD COLUMN     "frequencyHz" INTEGER,
ADD COLUMN     "gainDb" DECIMAL(6,2),
ADD COLUMN     "hdop" DECIMAL(4,2),
ADD COLUMN     "locateMode" "LocateMode",
ADD COLUMN     "phaseDeg" DECIMAL(6,2),
ADD COLUMN     "satellites" INTEGER,
ADD COLUMN     "signalDb" DECIMAL(6,2),
ADD COLUMN     "vAccuracy" DECIMAL(7,3);

-- CreateIndex
CREATE UNIQUE INDEX "devices_orgId_serialNumber_key" ON "devices"("orgId", "serialNumber");
