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") }