ADR-025 — The migration that drops TenantSettings applies late updates only
Date: 2026-10-26 Status: Accepted Supersedes in part: ADR-023 §5 — "the migration that drops the table runs [the reconciliation] first".
Context
ADR-023 §5 froze tenancy.TenantSettings for one release and had the migration that drops it run the post-rollout reconciliation first (TenantSettingsCopy.Reconcile: refresh the copies whose legacy row changed later, then insert the active legacy rows that have no copy), so a forgotten reconciliation could not lose the late writes of the old pods.
Release 2.5 added the generic settings management: an override of a tenant can be reset (the scope screen, DELETE {Bff}/settings/scopes/Tenant/{id}/overrides/{key}), which deletes its row from settings.SettingValues. The legacy row it was copied from is still active in the frozen table. A reset leaves no trace that tells it apart from a late write the copy missed: in both cases the legacy row has no copy, and the copy kept the source's timestamps, so neither side records when the copy happened. Inserting every missing row at drop time would bring back overrides reset in 2.4/2.5 — for the Entra settings, a directory an administrator stopped trusting.
Decision
DropTenantSettings runs only the refresh part of the reconciliation (TenantSettingsCopy.RefreshChangedIfPresent): an existing copy whose legacy row was updated after it (s.UpdatedAt > COALESCE(v.UpdatedAt, v.CreatedAt)) takes the legacy value. It never inserts a missing row. Then it drops the table, in the same transaction; both steps are guarded for a database where the table is already gone.
The full reconciliation stays in the code (TenantSettingsCopy.Reconcile) and shipped as TenantSettingsReconcile.sql, for the one deploy that still needs it.
Consequences
- A tenant override reset in 2.4/2.5 stays reset after the drop.
- A row an old (2.3) pod inserted during the rollout of 2.4 and that nobody reconciled is not copied by the drop. Runbook 03 lists, before the migration, the active legacy rows without a copy, for the operator to decide (run the full reconciliation, or let them go).
- A deploy coming straight from 2.3 must drain the old revision and run the full reconciliation (
TenantSettingsReconcile.sql) before applyingDropTenantSettings; applying everything at once (the API at boot) needs the old revision stopped first, or a stop at 2.5.x. settings.UserPreferences(ADR-024) has the same shape; the migration that drops it decides the same question for itself.