fix(admin): preserve hierarchy enabled_at on flip-off; add disabled_at for forensics#3475
Merged
bokelley merged 1 commit intoApr 28, 2026
Merged
Conversation
…t for forensics Migration 450 nulled auto_provision_hierarchy_enabled_at when the flag was flipped off, destroying the forensic record of when the feature was last active. Adds auto_provision_hierarchy_disabled_at TIMESTAMPTZ NULL and updates the trigger so flip-off sets disabled_at = NOW() and preserves enabled_at. The cohort gate in autoLinkByVerifiedDomain continues to read only enabled_at as authoritative — this change does not alter gate semantics. Partial fix for #3466. IP/user-agent audit enrichment deferred separately. Session: https://claude.ai/code/session_01Pn9rJFGQxPJpKGfUyF6W2v
4 tasks
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.
Refs #3466. Delivers acceptance criteria items 2–4 only. Item 1 (IP + user-agent in audit details) is deferred — see triage comment on #3466 for the compliance decision needed first.
Summary
Migration 450 nulled
auto_provision_hierarchy_enabled_atwhenauto_provision_brand_hierarchy_childrenwas flipped off, silently destroying the forensic record of when the feature was last active. This PR:auto_provision_hierarchy_disabled_at TIMESTAMPTZ NULLtoorganizations(migration 452)track_auto_provision_hierarchy_enabled_attrigger so flip-off setsdisabled_at = NOW()and preservesenabled_at(which the cohort gate inautoLinkByVerifiedDomainreads exclusively — gate semantics unchanged)OrganizationTS interfaceorg-auto-provision-toggles,find-paying-org-for-domain) to match the new semantics and adds an enable → disable → re-enable cycle testA complete
(enabled_at, disabled_at)pair lets incident response trace the full on/off cycle without losing the original opt-in timestamp.Non-breaking justification
Adds a single nullable column with no DEFAULT; existing rows get NULL (no table rewrite). No read path or gate logic changed. The
Organizationinterface addition is additive.Pre-PR review
CREATE OR REPLACE FUNCTIONis correct (PostgreSQL binds triggers by function name); test cycle assertions are sound; no flakiness risk. Nit: add trigger name to migration comment (not blocking).disabled_atcorrectly DB-only (not surfaced in GET /domains API);ADD COLUMN IF NOT EXISTSon nullable column is metadata-only in PG 11+, no lock concern. Identified blocker (stale assertion infind-paying-org-for-domain.test.ts) — fixed in this commit.Session: https://claude.ai/code/session_01Pn9rJFGQxPJpKGfUyF6W2v
Generated by Claude Code