ROX-32721: Add migration to backfill deployment_type and enforcement_count#20031
Draft
dashrews78 wants to merge 3 commits intodashrews/add-columns-32721from
Draft
ROX-32721: Add migration to backfill deployment_type and enforcement_count#20031dashrews78 wants to merge 3 commits intodashrews/add-columns-32721from
dashrews78 wants to merge 3 commits intodashrews/add-columns-32721from
Conversation
|
Skipping CI for Draft Pull Request. |
Contributor
Author
|
This change is part of the following stack: Change managed by git-spice. |
Contributor
🚀 Build Images ReadyImages are ready for commit cd5e37e. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-665-gcd5e37e583 |
c70f096 to
5413be2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dashrews/add-columns-32721 #20031 +/- ##
==============================================================
+ Coverage 49.61% 49.62% +0.01%
==============================================================
Files 2765 2767 +2
Lines 208707 208950 +243
==============================================================
+ Hits 103548 103693 +145
- Misses 97497 97568 +71
- Partials 7662 7689 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…count Three-phase migration that avoids walking the full alerts table: 1. DDL: Add deployment_type (varchar) and enforcementcount (integer) columns via GORM CreateTable (idempotent, instant in Postgres). 2. Backfill deployment_type via JOIN with deployments table (pure SQL, no blob deserialization). Orphaned alerts (deployment deleted) fall back to reading the value from the serialized blob. 3. Backfill enforcement_count only for the small subset of active alerts with enforcement (state=ACTIVE AND enforcement_action!=0). These rows are deserialized, the count is computed, and both the column and serialized blob are updated to maintain consistency. The migration is idempotent and backwards compatible -- old code ignores the new columns, and pre-migration queries continue to work. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migrations cannot import pkg/alert/convert (roxvet restriction). Remove the compile-time sync check and replace with a comment noting the dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add migration import to migrator/runner/all.go and increment CurrentDBVersionSeqNum from 223 to 224. These were generated by make bootstrap_migration but missed from the initial commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5413be2 to
cd5e37e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three-phase migration that avoids walking the full alerts table:
DDL: Add deployment_type (varchar) and enforcementcount (integer) columns
via GORM CreateTable (idempotent, instant in Postgres).
Backfill deployment_type via JOIN with deployments table (pure SQL, no
blob deserialization). Orphaned alerts (deployment deleted) fall back to
reading the value from the serialized blob.
Backfill enforcement_count only for the small subset of active alerts
with enforcement (state=ACTIVE AND enforcement_action!=0). These rows
are deserialized, the count is computed, and both the column and
serialized blob are updated to maintain consistency.
The migration is idempotent and backwards compatible -- old code ignores
the new columns, and pre-migration queries continue to work.
Partially generated by AI.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Description
change me!
User-facing documentation
Testing and quality
Automated testing
How I validated my change
change me!