From dd6124bff942e2723c9b1ef3f1d1b9d5e66edc2f Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Mon, 24 Feb 2025 17:09:21 -0500 Subject: [PATCH] Add `android_devices` to hosts-related tables to delete (#26568) --- server/datastore/mysql/hosts.go | 1 + server/datastore/mysql/hosts_test.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/server/datastore/mysql/hosts.go b/server/datastore/mysql/hosts.go index e413fa239b..5246056554 100644 --- a/server/datastore/mysql/hosts.go +++ b/server/datastore/mysql/hosts.go @@ -542,6 +542,7 @@ var hostRefs = []string{ "host_mdm_actions", "host_calendar_events", "upcoming_activities", + "android_devices", } // NOTE: The following tables are explicity excluded from hostRefs list and accordingly are not diff --git a/server/datastore/mysql/hosts_test.go b/server/datastore/mysql/hosts_test.go index a7fb9b04e3..f065a34b7a 100644 --- a/server/datastore/mysql/hosts_test.go +++ b/server/datastore/mysql/hosts_test.go @@ -7055,6 +7055,13 @@ func testHostsDeleteHosts(t *testing.T, ds *Datastore) { require.NoError(t, err) require.True(t, added) + // create an android device from this host + _, err = ds.writer(context.Background()).Exec(` + INSERT INTO android_devices (host_id, device_id) + VALUES (?, ?); + `, host.ID, uuid.NewString()) + require.NoError(t, err) + // Check there's an entry for the host in all the associated tables. for _, hostRef := range hostRefs { var ok bool