Skip to content

v1-to-v2 report migration script with strategy/orchestrator architecture #818

@anth-volk

Description

@anth-volk

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:

  1. Reads v1 report references from localStorage
  2. Fetches each v1 report's simulations, policies, and populations from the v1 API
  3. Creates equivalent v2 resources (policies, households/populations, analyses) via the v2 API
  4. Updates localStorage references to point to the new v2 resources
  5. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions