From b107262d60eb74f46d6096fa309cd17c84135f5e Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Thu, 18 Jun 2026 03:25:09 +0200 Subject: [PATCH] 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. --- .../20250618_add_mdm_health_columns/migration.sql | 11 +++++++++++ backend/prisma/schema.prisma | 1 + 2 files changed, 12 insertions(+) create mode 100644 backend/prisma/migrations/20250618_add_mdm_health_columns/migration.sql diff --git a/backend/prisma/migrations/20250618_add_mdm_health_columns/migration.sql b/backend/prisma/migrations/20250618_add_mdm_health_columns/migration.sql new file mode 100644 index 0000000..d1f3280 --- /dev/null +++ b/backend/prisma/migrations/20250618_add_mdm_health_columns/migration.sql @@ -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"); diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index b4f1673..12f4961 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -1123,6 +1123,7 @@ model UserDevice { @@unique([userId, deviceId]) @@index([userId]) @@index([deviceId]) + @@index([mdmId]) @@map("user_devices") @@schema("rebreak") }