-- App-path ingest idempotency + provenance (Sprint 2, S2-a; SRS-SYN-2/7, §3.4.2).
-- Adds the UUIDv7 idempotency key and forward-compat provenance tags to locate_points.

-- CreateEnum
CREATE TYPE "PointOrigin" AS ENUM ('APP', 'LOCATOR', 'MAGLINK');

-- CreateEnum
CREATE TYPE "PointUploadPath" AS ENUM ('APP_MQTT', 'DEVICE_MQTT', 'REST_BATCH');

-- AlterTable
ALTER TABLE "locate_points" ADD COLUMN     "pointId" TEXT,
ADD COLUMN     "origin" "PointOrigin" NOT NULL DEFAULT 'LOCATOR',
ADD COLUMN     "uploadPath" "PointUploadPath",
ADD COLUMN     "originClientId" TEXT,
ADD COLUMN     "createdAt" TIMESTAMPTZ(6);

-- CreateIndex
CREATE UNIQUE INDEX "locate_points_pointId_key" ON "locate_points"("pointId");

-- CreateIndex
CREATE INDEX "locate_points_jobId_createdAt_idx" ON "locate_points"("jobId", "createdAt");
