Problem
Users who created reports (household analyses and economy-wide simulations) on the v1 API need those reports migrated to v2. There is no automated migration path — users would lose access to their saved work when the frontend switches to API v2.
Solution
Build a client-side migration script that:
- Reads v1 report references from localStorage
- Fetches each v1 report's simulations, policies, and populations from the v1 API
- Creates equivalent v2 resources (policies, households/populations, analyses) via the v2 API
- Updates localStorage references to point to the new v2 resources
- Provides a cleanup step to remove old v1 references
Architecture
- Strategy layer (
strategies.ts): Individual migration functions for each resource type (policy, household, population, economy simulation, user report association)
- Orchestrator layer (
orchestrators.ts): Coordinates multi-step migration of a full report, handling dependencies between resources
- Detection (
detect.ts): Identifies which localStorage entries need migration
- Cleanup (
cleanup.ts): Removes v1 references after successful migration
Each strategy is independently testable and the orchestrator handles error categorization (per-report success/failure without blocking other reports).
Problem
Users who created reports (household analyses and economy-wide simulations) on the v1 API need those reports migrated to v2. There is no automated migration path — users would lose access to their saved work when the frontend switches to API v2.
Solution
Build a client-side migration script that:
Architecture
strategies.ts): Individual migration functions for each resource type (policy, household, population, economy simulation, user report association)orchestrators.ts): Coordinates multi-step migration of a full report, handling dependencies between resourcesdetect.ts): Identifies which localStorage entries need migrationcleanup.ts): Removes v1 references after successful migrationEach strategy is independently testable and the orchestrator handles error categorization (per-report success/failure without blocking other reports).