Skip to content

47713 auld software update assets migration - #50036

Merged
andymFleet merged 6 commits into
mainfrom
47713-auld-software-update-assets-migration
Jul 28, 2026
Merged

47713 auld software update assets migration#50036
andymFleet merged 6 commits into
mainfrom
47713-auld-software-update-assets-migration

Conversation

@andymFleet

@andymFleet andymFleet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #47713

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

Database migrations

  • Checked schema for all modified table for columns that will auto-update timestamps during migration.
  • Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.
  • Ensured the correct collation is explicitly set for character columns (COLLATE utf8mb4_unicode_ci).

Summary by CodeRabbit

  • New Features

    • Added support for tracking available Apple OS update assets and supported devices.
    • Added per-host Apple OS update targets, deadlines, and resolution status.
    • Added configuration options for host target OS versions and deadlines.
  • Database

    • Updated the MySQL schema and migration seed data to include the new tables and fleet variables, and to reflect updated migration/status metadata.
  • Tests

    • Added migration tests to validate table creation, constraints, defaults, and upsert behavior.

@andymFleet
andymFleet requested a review from a team as a code owner July 28, 2026 09:23
Copilot AI review requested due to automatic review settings July 28, 2026 09:23
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds MySQL migrations for Apple software-update asset metadata and per-host target updates, including keys, defaults, timestamps, and constraints. Adds migrations and tests for host target OS version and deadline fleet variables. Regenerates schema seed data for the new tables, fleet variables, and migration status entries.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The migrations, tests, schema updates, and fleet variable inserts match the linked issue's table definitions and acceptance criteria.
Out of Scope Changes check ✅ Passed The schema seed bumps appear tied to regenerating the database schema, and no unrelated code changes are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title matches the main change: a migration for AULD software update assets.
Description check ✅ Passed The description includes the linked issue, migration/database checks, and testing items, with no clear missing required section for this PR.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 47713-auld-software-update-assets-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go (1)

25-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the timestamp update contract.

This only asserts that first_seen_at is initialized. Add an update/upsert-path assertion that first_seen_at remains unchanged while updated_at advances. Based on PR objective: “Preserve updated_at behavior for asset upserts and first_seen_at behavior for initial inserts.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go`
around lines 25 - 36, Extend the migration test’s asset update/upsert flow after
the initial insert to capture the original first_seen_at and updated_at values,
perform the upsert, then assert first_seen_at is unchanged while updated_at
advances. Keep the existing nullable expiration_date and initial first_seen_at
assertions, and use the asset upsert/update symbols already defined in the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go`:
- Around line 25-36: Extend the migration test’s asset update/upsert flow after
the initial insert to capture the original first_seen_at and updated_at values,
perform the upsert, then assert first_seen_at is unchanged while updated_at
advances. Keep the existing nullable expiration_date and initial first_seen_at
assertions, and use the asset upsert/update symbols already defined in the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9181f289-65f5-4a44-8a5a-639a669e60b9

📥 Commits

Reviewing files that changed from the base of the PR and between 0504e59 and 9db4f2f.

📒 Files selected for processing (5)
  • server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates.go
  • server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go
  • server/datastore/mysql/migrations/tables/20260727084359_AddHostTargetOSVersionAndDeadlineFleetVars.go
  • server/datastore/mysql/migrations/tables/20260727084359_AddHostTargetOSVersionAndDeadlineFleetVars_test.go
  • server/datastore/mysql/schema.sql

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the initial MySQL schema and migrations for AULD software-update assets caching and per-host “resolved target OS version/deadline” tracking, and registers the corresponding Fleet template variables in fleet_variables.

Changes:

  • Add apple_software_update_assets and host_mdm_apple_os_updates tables (schema + migration + tests).
  • Register FLEET_VAR_HOST_TARGET_OS_VERSION and FLEET_VAR_HOST_TARGET_OS_DEADLINE in fleet_variables (migration + tests).
  • Regenerate server/datastore/mysql/schema.sql to include the new tables, variables, and migration status entries.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/datastore/mysql/schema.sql Regenerated schema dump including the two new tables and the two new fleet_variables rows.
server/datastore/mysql/migrations/tables/20260727084359_AddHostTargetOSVersionAndDeadlineFleetVars.go Migration inserting the two new Fleet variables with deterministic created_at.
server/datastore/mysql/migrations/tables/20260727084359_AddHostTargetOSVersionAndDeadlineFleetVars_test.go Tests verifying the variables are absent before and present after the migration (and is_prefix=0).
server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates.go Migration creating the apple_software_update_assets and host_mdm_apple_os_updates tables.
server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go Tests validating key constraints/defaults on both new tables (unique key, enum, NOT NULL, PK uniqueness, defaults).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.31034% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.97%. Comparing base (8e0c038) to head (d7fe099).

Files with missing lines Patch % Lines
...CreateAppleSoftwareUpdateAssetsAndHostOSUpdates.go 84.21% 4 Missing and 2 partials ⚠️
...4359_AddHostTargetOSVersionAndDeadlineFleetVars.go 70.00% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #50036      +/-   ##
==========================================
- Coverage   67.99%   67.97%   -0.03%     
==========================================
  Files        3924     3924              
  Lines      250120   250101      -19     
  Branches    13330    13123     -207     
==========================================
- Hits       170072   170004      -68     
- Misses      64747    64792      +45     
- Partials    15301    15305       +4     
Flag Coverage Δ
backend 69.38% <79.31%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings July 28, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 28, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go:59

  • This updated_at assertion can be flaky: the insert and subsequent upsert may happen within the same CURRENT_TIMESTAMP(6) tick, causing gotUpdatedAtAfterUpsert.After(gotUpdatedAt) to fail even though ON UPDATE is working. Add a small sleep before the upsert to ensure time advances between statements.
	require.True(t, gotFirstSeenAt.Equal(gotFirstSeenAtAfterUpsert),
		"first_seen_at must not change on upsert")
	require.True(t, gotUpdatedAtAfterUpsert.After(gotUpdatedAt),
		"updated_at must advance on upsert")

Copilot AI review requested due to automatic review settings July 28, 2026 14:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

server/datastore/mysql/migrations/tables/20260727083533_CreateAppleSoftwareUpdateAssetsAndHostOSUpdates_test.go:52

  • The test asserts updated_at strictly increases on the upsert, but the upsert happens immediately after the initial insert and can share the same CURRENT_TIMESTAMP(6) value, making this assertion potentially flaky. Add a small sleep (or otherwise ensure the server timestamp advances) before running the upsert so the After check is reliable.
	// An upsert on the same (class, product_version, build) — the shape the GDMF
	// refresh uses — keeps first_seen_at from the original insert while
	// updated_at advances. posting_date is changed so the row is a real update:
	// MySQL leaves updated_at alone when no column value actually changes.
	execNoErr(t, db, `

@andymFleet
andymFleet merged commit f1228c8 into main Jul 28, 2026
44 checks passed
@andymFleet
andymFleet deleted the 47713-auld-software-update-assets-migration branch July 28, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AULD: Migration

3 participants