[PM-37470] Add UseRiskInsights data migration for existing Enterprise organizations#7691
Draft
AlexRubik wants to merge 2 commits into
Draft
[PM-37470] Add UseRiskInsights data migration for existing Enterprise organizations#7691AlexRubik wants to merge 2 commits into
AlexRubik wants to merge 2 commits into
Conversation
Set UseRiskInsights = 1 on existing Organization rows with Enterprise plan types (4, 5, 10, 11, 14, 15, 19, 20). Batched and idempotent. [PM-37470]
Adds equivalent UPDATE migration for MySQL, Postgres, and SQLite providers used by self-hosted instances. Mirrors the MSSQL script. [PM-37470]
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7691 +/- ##
=======================================
Coverage 64.85% 64.85%
=======================================
Files 2140 2140
Lines 94622 94622
Branches 8443 8443
=======================================
Hits 61370 61370
Misses 31156 31156
Partials 2096 2096 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
🎟️ Tracking
PM-37470
Parent epic: PM-37469
📔 Objective
Add the data migration step from the Organization Ability README for
UseRiskInsights. SetsUseRiskInsights = 1on every existingOrganizationrow with an Enterprise plan type (4, 5, 10, 11, 14, 15, 19, 20). Covers MSSQL (cloud) and the three EF providers (MySQL, Postgres, SQLite) used by self-host.The column has existed since
2024-11-25_00_AddUseRiskInsightsToOrganization.sqlbut the README's step 4 (data migration for existing orgs) was never performed. A stopgap one-off datafix (DBOPS-59) handled cloud in Dec 2025, but orgs created since are missing the flag and self-host instances never received it. This PR delivers the proper repeatable migration.Re-runs are no-ops: MSSQL uses a
WHERE UseRiskInsights = 0guard so the batched loop exits immediately when there is nothing to update; EF variants set1over1which is idempotent by construction.Other subtasks under the parent epic handle plan-definition mapping (PM-37471), admin portal toggle (PM-37473), self-host license claims (PM-37474), re-enabling the endpoint guard (PM-37475), and client-side divergence (PM-37476).
Mirrors the pattern from PM-35253 (#7489)
UseInviteLinksDataMigration. SQL formatted per the Bitwarden SQL style guide (each top-level keyword on its own line).🤖 Testing
The
IMigrationTesterServiceinfrastructure was disabled in PM-37482 (#7633, May 14 2026) due to flakiness, so no automated migration integration test ships with this PR. Verification is manual:UseRiskInsights = 0.1and the non-Enterprise row stays at0.@@ROWCOUNT = 0.dotnet ef database update. Confirm same outcome.If this PR sits in review across a calendar shift, rename the MSSQL script's date prefix to the actual merge date.