Skip to content

WAIT: Add OrganizationType base-data model backing org and registration forms#1886

Draft
maebeale wants to merge 3 commits into
mainfrom
maebeale/organization-type-model
Draft

WAIT: Add OrganizationType base-data model backing org and registration forms#1886
maebeale wants to merge 3 commits into
mainfrom
maebeale/organization-type-model

Conversation

@maebeale

@maebeale maebeale commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

🤖 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, Publishable OrganizationType model under Base data, so the list can change without a deploy.

How did you approach the change?

  • New OrganizationType model (Publishable, name + published + description), mirroring the Sector base-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.
  • Public registration form builder reads options from OrganizationType.published_names, falling back to the canonical defaults when none are seeded (keeps test DBs without seeds working).
  • Canonical four are seeded as published via db/seeds.rb; the catch-all is plain "Other". agency_type_other (the free-text "Other" specify field) is retained.

Anything else to add?

  • Migration is schema-only (adds the nullable organization_type_id reference) — no data backfill. Existing organizations are left unclassified rather than mapped from their legacy agency_type strings.
  • The agency_type (string) column is left in place rather than dropped; the form no longer writes it.
  • New specs: model, request (CRUD + dependent nullify), and a form-builder case asserting it reads published type names.


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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.


# Published names for the forms, falling back to the canonical defaults when
# nothing is seeded yet.
def self.published_names

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@maebeale maebeale force-pushed the maebeale/organization-type-model branch from 16ad678 to 2dbeb8b Compare June 23, 2026 10:48
Copilot AI review requested due to automatic review settings June 23, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@maebeale maebeale changed the title Add OrganizationType base-data model backing org and registration forms WAIT: Add OrganizationType base-data model backing org and registration forms Jun 23, 2026
maebeale and others added 2 commits June 23, 2026 07:59
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>
@maebeale maebeale force-pushed the maebeale/organization-type-model branch from 1bcd8ec to 0a853fb Compare June 23, 2026 12:01
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants