Skip to content

Implement Soroban contract storage migration framework with rollback #519

Description

@Just-Bamford

Description

Problem

Contract upgrades can introduce changes to stored data structures. Existing storage values may no longer match the new expected schema, but there is no standardized migration framework for transforming existing state safely.

Without validation and rollback capabilities, an unsuccessful migration can leave applications with inconsistent or unusable state.

Solution

Create a versioned storage migration framework.

A migration should define a source schema/version, target schema/version, transformation function, validation step, and rollback strategy.

The framework should track migration progress and prevent the same migration from being applied repeatedly.

Acceptance Criteria

  • Storage migration framework is introduced.
  • Migrations define source and target versions.
  • Data transformation functions are supported.
  • Pre-migration validation is performed.
  • Post-migration integrity validation is performed.
  • Migration status is persisted.
  • Previously completed migrations are not re-applied.
  • Failed migrations expose structured error information.
  • Rollback support is available where the migration strategy permits it.
  • Tests cover successful migration, validation failure, partial failure, rollback, and repeated execution.
  • Exported through src/soroban/index.ts and src/index.ts.

Note for Contributors

Do not treat arbitrary rollback as automatically possible for destructive transformations. Define clear migration guarantees and validate state before mutating it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbackendBackend / SDK logicenhancementNew feature or requestsmart-contractSoroban contract related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions