fleet/server/datastore/mysql
Scott Gress b2e6162e51
Fix issue with GitOps incorrectly wiping policy stats (#43282)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #43273

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [X] Added/updated automated tests
- Added new test for this case (policies without software automation
being pushed by two different users), verified it fails on main and
passes on this branch
- [X] QA'd all new/changed functionality manually
- [X] Verified that changing `webhooks_and_tickets_enabled` on a policy
AND running gitops as another user doesn't wipe stats
- [X] Verified that changing `query` on a policy and running gitops does
wipe stats
- [X] Verified that changing `query` on a policy and running gitops does
wipe stats

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Fixed an issue where policy stats were incorrectly reset during GitOps
policy updates. Policy statistics now remain accurate when policies are
re-applied without modification to installation or script
configurations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-08 17:03:08 -05:00
..
migrations Add Windows awaiting configuration (#43067) 2026-04-07 20:17:16 -05:00
rdsauth slog migration: platform/mysql and related logic (#40072) 2026-02-19 08:27:24 -06:00
testdata Fixed dead rows accumulating in software host counts tables (#40288) 2026-02-24 15:35:02 -06:00
activities.go Don't clear past lock/wipe (#41504) 2026-03-13 15:21:24 -05:00
activities_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
aggregated_stats.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
aggregated_stats_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
android.go Clear Android cert records on unenroll. (#42920) 2026-04-02 14:59:09 -05:00
android_device_test.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_enterprise_test.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_enterprises.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
android_hosts.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_mysql.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_test.go Clear Android cert records on unenroll. (#42920) 2026-04-02 14:59:09 -05:00
app_configs.go Fix: incorrect timestamps returned for Label and Team creation (#38846) 2026-01-27 18:02:48 -03:00
app_configs_test.go Use lighter Team call when it's obviously safe to do so, comment potential areas for further improvement (#35587) 2025-11-17 17:25:45 -06:00
apple_mdm.go Rename Apple Business Manager in UI (#42584) 2026-04-08 11:14:19 -06:00
apple_mdm_ddm_test.go Updated SQL modes in tests to match production. (#31445) 2025-08-03 08:18:13 +02:00
apple_mdm_test.go Rename Apple Business Manager in UI (#42584) 2026-04-08 11:14:19 -06:00
ca_config_assets.go Add custom SCEP configs (#27045) 2025-03-14 12:16:51 -05:00
ca_config_assets_test.go Add custom SCEP configs (#27045) 2025-03-14 12:16:51 -05:00
calendar_events.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
calendar_events_test.go Handle null HostID on calendar webhook endpoint (#30130) 2025-06-23 13:10:10 -04:00
campaigns.go Add CleanupCompletedCampaignTargets to cleanup old campaign targets. (#32385) 2025-08-28 11:04:05 -05:00
campaigns_test.go Add CleanupCompletedCampaignTargets to cleanup old campaign targets. (#32385) 2025-08-28 11:04:05 -05:00
carves.go Authenticate carve block endpoint before parsing the "data" field (#39353) 2026-02-05 15:55:03 -03:00
carves_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
certificate_authorities.go Fixed GitOps failing to delete a certificate authority (#41693) 2026-03-16 15:51:28 -05:00
certificate_authorities_test.go Fixed GitOps failing to delete a certificate authority (#41693) 2026-03-16 15:51:28 -05:00
certificate_templates.go Added automatic Android cert retry (#42734) 2026-04-01 13:49:24 -05:00
certificate_templates_test.go make sure to reset fleet challenge when resending android cert (#42550) 2026-03-27 16:51:54 -04:00
challenges.go Fixed Android certificate enrollment failures caused by SCEP challenge expiration when devices were offline. (#38753) 2026-01-28 10:33:37 -06:00
conditional_access_bypass.go Rework conditional access policy bypass conditions to use critical column (#40736) 2026-03-05 17:05:03 -05:00
conditional_access_bypass_test.go Removed duplicate FlippingPoliciesForHost DB calls (#42845) 2026-04-06 10:11:07 -05:00
conditional_access_microsoft.go Changes to set compliance status on Entra on Windows hosts when processing policy results (#41903) 2026-03-18 12:57:49 -03:00
conditional_access_microsoft_test.go Changes to set compliance status on Entra on Windows hosts when processing policy results (#41903) 2026-03-18 12:57:49 -03:00
conditional_access_scep.go Okta IdP factor (#35143) 2025-11-07 16:19:25 -06:00
conditional_access_scep_test.go Okta IdP factor (#35143) 2025-11-07 16:19:25 -06:00
config.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
cron_stats.go Trigger vuln processing when it runs on a separate server (#39612) 2026-02-17 09:18:03 -06:00
cron_stats_test.go Fix issue with vuln jobs running in parallel. (#39806) 2026-02-16 13:59:40 -06:00
delete.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
delete_test.go Updated factory method for creating queries in tests 2023-07-07 09:05:51 -04:00
disk_encryption.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
disk_encryption_test.go Added new global activity when disk encryption key is escrowed (#31634) 2025-08-08 12:14:48 -04:00
email_changes.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
email_changes_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
errors.go Fix software installer error team -> fleet (#41070) 2026-03-05 17:28:52 -06:00
errors_test.go Fix software installer error team -> fleet (#41070) 2026-03-05 17:28:52 -06:00
fulltext.go Update to Go 1.24.1 (#27506) 2025-03-31 11:14:09 -05:00
fulltext_test.go Using '@' in target search causes 422 error response (#5148) 2022-04-19 09:28:49 -04:00
host_certificate_templates.go Android Wi-Fi profile withheld until cert installed on device (#42877) 2026-04-07 16:26:09 -05:00
host_certificate_templates_test.go Android Wi-Fi profile withheld until cert installed on device (#42877) 2026-04-07 16:26:09 -05:00
host_certificates.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
host_certificates_test.go DCSW: Allow Windows profiles to hit SCEP Proxy (#35041) 2025-11-06 11:14:49 -03:00
host_identity_scep.go ACME MDM -> main (#42926) 2026-04-02 15:56:31 -05:00
host_identity_scep_test.go Make orbit and Fleet Desktop not depend on server/service/ packages (#42231) 2026-03-26 10:59:42 -03:00
hosts.go Optimized PolicyQueriesForHost and ListPoliciesForHost SQL queries (#43035) 2026-04-06 08:50:18 -05:00
hosts_test.go Removed duplicate FlippingPoliciesForHost DB calls (#42845) 2026-04-06 10:11:07 -05:00
in_house_apps.go Backend: Support labels_include_all for installers/apps (#41324) 2026-03-18 13:27:53 -04:00
in_house_apps_test.go Move PostJSONWithTimeout to platform/http package and activity cleanup (#40561) 2026-02-26 17:39:10 -06:00
invites.go Order By Vulnerability (#40143) 2026-02-23 09:42:36 -07:00
invites_test.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
jobs.go Cancel batch execution API (#31757) 2025-08-11 15:17:57 -04:00
jobs_test.go Allow worker to filter queue by job type (#31556) 2025-08-06 17:22:48 -05:00
labels.go Allow hosts key to be empty for manual labels (#42022) 2026-03-20 10:36:14 -05:00
labels_test.go Removed duplicate FlippingPoliciesForHost DB calls (#42845) 2026-04-06 10:11:07 -05:00
linux_mdm.go Linux OS settings + disk encryption host filter fixes (#24200) 2024-11-26 19:26:22 -06:00
linux_mdm_test.go Added new global activity when disk encryption key is escrowed (#31634) 2025-08-08 12:14:48 -04:00
locks.go Optimize software_titles query to use indexes (#25722) 2025-01-23 15:48:21 -03:00
locks_test.go Improvements for select next Apple MDM command query. (#24128) 2024-12-05 12:02:48 -06:00
maintained_apps.go Use FMA names for macOS software (#42221) 2026-03-30 10:41:37 -06:00
maintained_apps_test.go Update software title names on FMA sync and upload (#42647) 2026-03-30 15:59:19 -04:00
mdm.go ACME MDM -> main (#42926) 2026-04-02 15:56:31 -05:00
mdm_idp_accounts_test.go Add support for fully-managed android devices (#39388) 2026-02-06 10:46:25 -05:00
mdm_test.go SyncML <Delete> Windows profiles (#42206) 2026-03-26 18:25:54 -05:00
microsoft_mdm.go Add Windows awaiting configuration (#43067) 2026-04-07 20:17:16 -05:00
microsoft_mdm_test.go Add Windows awaiting configuration (#43067) 2026-04-07 20:17:16 -05:00
migrations_test.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
mysql.go Added OTEL DB stats metrics, renamed trace attributes to expected OTEL names (#42097) 2026-03-20 11:07:58 -05:00
mysql_test.go Follow-up changes to observer live query bypass (#41146) 2026-03-11 13:42:33 -03:00
nanomdm_storage.go Set recovery lock password - mdm commands (#41217) 2026-03-12 06:06:56 -06:00
nanomdm_storage_test.go slog migration: platform/mysql and related logic (#40072) 2026-02-19 08:27:24 -06:00
operating_system_vulnerabilities.go Use swap table pattern and batch delete to improve DB access patterns for vuln cron (#41729) 2026-03-17 10:34:52 -05:00
operating_system_vulnerabilities_batch_test.go os_versions endpoint performance improvements (#34897) 2025-11-03 13:07:44 -06:00
operating_system_vulnerabilities_test.go Use swap table pattern and batch delete to improve DB access patterns for vuln cron (#41729) 2026-03-17 10:34:52 -05:00
operating_systems.go Differentiate between Windows Server Core and full desktop installations (#42034) 2026-03-21 10:03:57 -05:00
operating_systems_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs_test.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
password_reset.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
password_reset_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
policies.go Fix issue with GitOps incorrectly wiping policy stats (#43282) 2026-04-08 17:03:08 -05:00
policies_test.go Fix issue with GitOps incorrectly wiping policy stats (#43282) 2026-04-08 17:03:08 -05:00
queries.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
queries_test.go Show Manage Automations disabled button with tooltip on Queries page (#39302) 2026-02-09 15:16:28 -03:00
query_results.go Performance improvements for Host Reports (41540) 2026-03-26 07:04:18 -04:00
query_results_test.go Performance improvements for Host Reports (41540) 2026-03-26 07:04:18 -04:00
scep.go ACME MDM -> main (#42926) 2026-04-02 15:56:31 -05:00
scep_test.go Updated SQL modes in tests to match production. (#31445) 2025-08-03 08:18:13 +02:00
scheduled_queries.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
scheduled_queries_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
schema.sql Add Windows awaiting configuration (#43067) 2026-04-07 20:17:16 -05:00
scim.go Surface correct HTTP status on SCIM data constraint errors (40260) (#41530) 2026-03-13 13:22:10 -04:00
scim_test.go Resend Windows profiles on IDP variables change (#37032) 2025-12-10 15:08:01 -04:00
scripts.go Do not clear MDM lock state on "idle" after lock (#42799) (#42825) 2026-04-02 11:02:50 -04:00
scripts_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
secret_variables.go Implement clear passcode backend (#43072) 2026-04-07 15:23:59 -05:00
secret_variables_test.go Implement clear passcode backend (#43072) 2026-04-07 15:23:59 -05:00
sessions.go slog migration: initLogger + serve.go + cron + schedule (#40699) 2026-02-27 14:29:27 -06:00
sessions_test.go Include expiration info, drop "personalized", in MFA email (#24630) 2024-12-10 18:58:40 -06:00
setup_experience.go incorporate display name into setup experience ordering and enforce 1 at a time execution (#42393) 2026-04-06 11:51:39 -05:00
setup_experience_test.go incorporate display name into setup experience ordering and enforce 1 at a time execution (#42393) 2026-04-06 11:51:39 -05:00
software.go Return light software metadata when listing hosts filtered by software present only on a different team (#42519) 2026-03-30 21:33:21 -07:00
software_installers.go Delete unnecessary patch policies in batch set software installers (#43112) 2026-04-07 15:58:29 -04:00
software_installers_test.go incorporate display name into setup experience ordering and enforce 1 at a time execution (#42393) 2026-04-06 11:51:39 -05:00
software_test.go Return light software metadata when listing hosts filtered by software present only on a different team (#42519) 2026-03-30 21:33:21 -07:00
software_title_display_names.go Bugfix: use custom software title icon and display name in setup experience UI (#39223) 2026-02-03 14:56:16 -05:00
software_title_icons.go merge main 2026-03-18 14:49:08 -04:00
software_title_icons_test.go merge main 2026-03-18 14:49:08 -04:00
software_titles.go Pin FMA major version in GitOps (#43053) 2026-04-06 12:36:47 -04:00
software_titles_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
software_upgrade_code_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
statistics.go Add statistics for Entra conditional access (#41998) 2026-03-19 10:32:08 -03:00
statistics_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
targets.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
targets_test.go API + auth + UI changes for team labels (#37208) 2025-12-29 21:28:45 -06:00
teams.go SyncML <Delete> Windows profiles (#42206) 2026-03-26 18:25:54 -05:00
teams_test.go Add lock end user info migrations, API support and AccountConfiguration command updates (#40551) 2026-03-02 12:16:31 -05:00
testing_utils.go SyncML <Delete> Windows profiles (#42206) 2026-03-26 18:25:54 -05:00
unicode_test.go Bugfix: only count hosts that user has permission to see in count field of label endpoints (#18859) 2024-05-21 12:02:08 -04:00
users.go Fix TOCTOU race in last global admin protection (#42172) 2026-04-01 15:00:08 -03:00
users_test.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
vpp.go Immediately reject duplicate Android web-clips (#42704) 2026-03-31 09:34:12 -04:00
vpp_test.go merge main 2026-03-18 14:49:08 -04:00
vulnerabilities.go Atomic vulnerability count calculations (#35317) 2025-11-12 13:09:34 -07:00
vulnerabilities_test.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
windows_updates.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
windows_updates_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
wstep.go Add SCEP endpoint for host identity. (#30589) 2025-07-11 11:44:07 -03:00
wstep_test.go Move nanomdm dependency in monorepo (#16015) 2024-01-11 23:28:48 -03:00