fix(db): normalize legacy 'general fund' initiative_type to 'general_fund' (DO NOT MERGE)#153
Open
mlehotskylf wants to merge 5 commits into
Open
fix(db): normalize legacy 'general fund' initiative_type to 'general_fund' (DO NOT MERGE)#153mlehotskylf wants to merge 5 commits into
mlehotskylf wants to merge 5 commits into
Conversation
…fund' Two rows migrated from DynamoDB in 2022 have initiative_type = 'general fund' (space) instead of the canonical 'general_fund' (underscore) used by all new code. This causes them to be invisible on the General Funds filter tab and rejected by ValidInitiativeTypes on any update attempt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michal Lehotsky <mlehotsky@linuxfoundation.org>
Contributor
There was a problem hiding this comment.
Pull request overview
Normalizes legacy Postgres data migrated from DynamoDB where initiative_type was stored as the display string 'general fund' instead of the canonical code value 'general_fund', restoring correct backend validation and frontend filtering behavior for General Funds.
Changes:
- Add a SQL migration that updates any
initiatives.initiative_type = 'general fund'rows to'general_fund'. - Update
updated_onfor the affected rows as part of the same statement.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Python migration script restored DynamoDB's entityType quirk as 'general fund' (space) instead of the canonical 'general_fund' (underscore) used by ValidInitiativeTypes and all frontend code. Fix it at the source so production migration never produces the wrong value. The SQL migration (002) is kept to fix environments that ran the old script (e.g. DEV already has 2 affected rows). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michal Lehotsky <mlehotsky@linuxfoundation.org>
…cient The SQL migration was added to fix DEV rows written by the old script, but: - On prod the fixed Python script runs before the app deploys, so 002 is a no-op - SQL migrations run forever on every new environment — wrong mechanism for a one-time dev cleanup - DEV can be fixed with a manual UPDATE or by re-running the fixed script Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michal Lehotsky <mlehotsky@linuxfoundation.org>
OSTIF initiatives are security audits run by the Open Source Technology Improvement Fund. Reclassify them to security_audit so they match ValidInitiativeTypes and appear correctly in the UI filter. The OSTIF-specific detail block still reads the raw DynamoDB entityType (before normalisation) to correctly populate initiative_ostif_detail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michal Lehotsky <mlehotsky@linuxfoundation.org>
Legacy initiative types 'other' and 'community' have no dedicated UI representation. Rather than renaming them in the DB, surface them under the General Fund tab: - Backend: when filtering by general_fund, query also includes 'other' and 'community' rows via ANY($1) - Frontend card: map 'other' and 'community' to the general_fund card config (label, icon, colours) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Michal Lehotsky <mlehotsky@linuxfoundation.org>
emlimlf
approved these changes
Jun 15, 2026
lewisojile
approved these changes
Jun 15, 2026
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.
Summary
Audited all initiative types across DynamoDB, the migration script, backend validation, and UI filters. Found several mismatches between what the migration writes to the DB and what the rest of the stack expects. This PR fixes all of them.
Type mismatches fixed
initiative(=general fund)general fund(space)general_fundostifostifsecurity_auditLegacy types surfaced under General Fund
other(25 rows) andcommunity(3 rows) have no dedicated UI category. Rather than renaming them in the DB, they are surfaced transparently under the General Fund tab:general_fundfilter query usesANY($1)to also includeotherandcommunityrowsotherandcommunityare mapped to thegeneral_fundcard config (same label, icon, colours)Impact without this fix: on go-live, 123 general fund initiatives would be invisible on the General Funds tab and rejected by type validation on updates; 11 OSTIF initiatives would show with default fallback styling.
Changes
backend/db/scripts/migrate_dynamo_to_postgres.py— normaliseinitiative→general_fundandostif→security_audit; fix OSTIF detail block to read raw DynamoDB type before normalisationbackend/internal/infrastructure/db/initiative_repository.go—general_fundfilter includesotherandcommunityviaANY($1)frontend/app/components/shared/components/initiative-card/initiative-card.config.ts— mapotherandcommunitytogeneral_fundcard configTest plan
Testing Crowdfunding project Creation,Test Crowdfunding Projectnow haveinitiative_type = 'general_fund')general fundorostifrows produced🤖 Generated with Claude Code