feat(mdm): add NanoMDM health columns migration for UserDevice

Adds mdm_id, mdm_enrolled, mdm_supervised, mdm_last_seen_at and an
index on mdm_id. Uses IF NOT EXISTS to stay idempotent because mdm_id
was added manually before the migration was created.
This commit is contained in:
chahinebrini 2026-06-18 03:25:09 +02:00
parent 9065543b5a
commit b107262d60
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,11 @@
-- Spiegel-Spalten für NanoMDM Enrollment/Supervision-Status auf UserDevice.
-- mdm_id wurde manuell hinzugefügt; IF NOT EXISTS macht die Migration idempotent.
ALTER TABLE "rebreak"."user_devices"
ADD COLUMN IF NOT EXISTS "mdm_id" TEXT,
ADD COLUMN IF NOT EXISTS "mdm_enrolled" BOOLEAN,
ADD COLUMN IF NOT EXISTS "mdm_supervised" BOOLEAN,
ADD COLUMN IF NOT EXISTS "mdm_last_seen_at" TIMESTAMPTZ(6);
CREATE INDEX IF NOT EXISTS "user_devices_mdm_id_idx"
ON "rebreak"."user_devices"("mdm_id");

View File

@ -1123,6 +1123,7 @@ model UserDevice {
@@unique([userId, deviceId])
@@index([userId])
@@index([deviceId])
@@index([mdmId])
@@map("user_devices")
@@schema("rebreak")
}