WAIT: Add OrganizationType base-data model backing org and registration forms#1886
Draft
maebeale wants to merge 3 commits into
Draft
WAIT: Add OrganizationType base-data model backing org and registration forms#1886maebeale wants to merge 3 commits into
maebeale wants to merge 3 commits into
Conversation
maebeale
commented
Jun 23, 2026
|
|
||
| organization.where.not(agency_type: [ nil, "" ]).find_each do |org| | ||
| match = org_type.where("LOWER(name) = LOWER(?)", org.agency_type).first | ||
| org.update_columns(organization_type_id: match.id) if match |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: Backfill uses lightweight anonymous AR classes (not the real models) so the migration stays stable if OrganizationType/Organization change later, and update_columns to skip validations/callbacks during the data move. Mapping is case-insensitive against the seeded type names.
maebeale
commented
Jun 23, 2026
|
|
||
| # Published names for the forms, falling back to the canonical defaults when | ||
| # nothing is seeded yet. | ||
| def self.published_names |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: Fallback to DEFAULT_NAMES keeps the org + registration forms populated when no types are published yet — notably fresh test DBs that do not load seeds, so the existing form-builder spec stays green without seeding.
16ad678 to
2dbeb8b
Compare
Replace the hardcoded "Organization Type" classification list (duplicated across the organization profile form and the public registration form builder) with an admin-managed, Publishable OrganizationType model under "Base data". Organizations now belong_to :organization_type, and the profile form, index, and show read from the association. Existing agency_type strings are backfilled onto the matching types so no data is lost; the canonical four are seeded as published. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the "(please specify below)" parenthetical from the option label. The migration backfill aliases the legacy string onto the renamed record so existing organizations keep their classification. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1bcd8ec to
0a853fb
Compare
Keep it schema-only (add the nullable reference). The canonical types are still seeded via db/seeds.rb; existing organizations are left unclassified rather than mapped from their legacy agency_type strings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
🤖 PR, suggested 👤 review level: 📖 Read — new Publishable base-data model with a schema-only migration (no data transform); contained logic, low blast radius
What is the goal of this PR and why is this important?
The "Organization Type" classification list was hardcoded and duplicated in two places (the organization profile form and the public registration form builder). This makes it an admin-managed,
PublishableOrganizationTypemodel under Base data, so the list can change without a deploy.How did you approach the change?
OrganizationTypemodel (Publishable, name + published + description), mirroring theSectorbase-data pattern: controller, policy, decorator, factory, full CRUD views, route, admin "Base data" card.Organization belongs_to :organization_type(optional). Profile form, index ("Designations" cell), and show page now read from the association.OrganizationType.published_names, falling back to the canonical defaults when none are seeded (keeps test DBs without seeds working).db/seeds.rb; the catch-all is plain "Other".agency_type_other(the free-text "Other" specify field) is retained.Anything else to add?
organization_type_idreference) — no data backfill. Existing organizations are left unclassified rather than mapped from their legacyagency_typestrings.agency_type(string) column is left in place rather than dropped; the form no longer writes it.