You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate registration policies from JSONB to ActiveRecord (#11238)
Registration policies and their buckets were stored as JSONB blobs on
events/event_proposals, making bucket_key references in signups,
signup_requests, and signup_ranked_choices plain strings with no
referential integrity (the cause of #11229). This moves them into real
registration_policies/registration_policy_buckets tables.
Key design points:
- Buckets are updated in place on edit (matched by key, never renamed)
rather than replaced wholesale, so row identity is stable for
anything that didn't change -- deliberately compatible with a future
bucket_key -> FK conversion on signups (still deferred).
- External API (GraphQL field names, Liquid) is unchanged: anything/
not_counted are preserved as aliases over the new flex/counted
columns, since nothing in the frontend actually shows a bucket's key
to users, only its name.
- No accepts_nested_attributes_for, attributes= override, or ==
override -- this app doesn't use Rails form helpers, and explicit
named methods (build_from_hash, equivalent_to?) are easier to trace
than hooking into Rails' implicit machinery.
- EventProposal is migrated in this same pass; a shared
HasRegistrationPolicy concern unifies what was previously duplicated
apply-the-change logic between Event and EventProposal's write paths.
Verified against a full copy of production data end to end, which
caught a few real bugs before they went anywhere near a shared
database: an id leak in RegistrationPolicy#as_json that corrupted
detached-policy comparisons, a stale association cache in bucket sync
that let a destroyed bucket reappear in an audit log, a missing
registration_policy default in AcceptEventProposalService now that the
column is NOT NULL, and a dependent: option conflict that blocked
destroying an event that owned its own policy.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments