Background
Registration policies (and their buckets) are currently stored as JSONB objects on the events table. This makes it impossible to enforce referential integrity on fields like bucket_key and requested_bucket_key in signups, signup_requests, and signup_ranked_choices — they're just free-text strings that reference a key in a JSON blob.
This has caused real problems: #11229 was filed because changes to bucket keys could silently invalidate those references, and we had to add application-level logic to detect and remap them.
Proposed Change
Extract registration policies and their buckets into proper database tables:
registration_policies table (belongs to event)
registration_policy_buckets table (belongs to registration_policy, has key, name, description, slots_limited, total_slots, minimum_slots, preferred_slots, anything, not_counted, etc.)
Then migrate bucket_key and requested_bucket_key on signups, signup_requests, and signup_ranked_choices to be integer foreign key columns referencing registration_policy_buckets.
Benefits
Considerations
- This is a significant migration — the JSONB serialization is used throughout the codebase (GraphQL types, forms, services)
- The
RegistrationPolicy and RegistrationPolicy::Bucket value objects would need to either be replaced or backed by ActiveRecord models
- The
EventChangeRegistrationPolicyService logic would need to be revisited
- Liquid drops and other serialization points would need updating
Background
Registration policies (and their buckets) are currently stored as JSONB objects on the
eventstable. This makes it impossible to enforce referential integrity on fields likebucket_keyandrequested_bucket_keyinsignups,signup_requests, andsignup_ranked_choices— they're just free-text strings that reference a key in a JSON blob.This has caused real problems: #11229 was filed because changes to bucket keys could silently invalidate those references, and we had to add application-level logic to detect and remap them.
Proposed Change
Extract registration policies and their buckets into proper database tables:
registration_policiestable (belongs toevent)registration_policy_bucketstable (belongs toregistration_policy, haskey,name,description,slots_limited,total_slots,minimum_slots,preferred_slots,anything,not_counted, etc.)Then migrate
bucket_keyandrequested_bucket_keyonsignups,signup_requests, andsignup_ranked_choicesto be integer foreign key columns referencingregistration_policy_buckets.Benefits
Considerations
RegistrationPolicyandRegistrationPolicy::Bucketvalue objects would need to either be replaced or backed by ActiveRecord modelsEventChangeRegistrationPolicyServicelogic would need to be revisited