Context
SubscriptionData, EscrowAgreement, Card and PaymentChannel are stored directly as contracttype structs in persistent storage. Adding a field to any of them silently breaks deserialization of existing entries after an upgrade, and contract-upgrade has no story for migrating state — only for swapping WASM.
Scope
- Add a
schema_version: u32 field to every persisted struct and a StorageVersion instance key per contract.
- Implement a
migrate(from_version) entrypoint gated to admin/guardian, callable only once per version step.
- Write read paths that accept the previous schema version and upgrade lazily on write where feasible.
- Add tests that write v1 data, upgrade the contract, and read it back through v2 code.
Acceptance criteria
Files / areas
contracts/contracts/*/src/lib.rs, contracts/contracts/contract-upgrade/src/lib.rs, contracts/DEPLOYMENT.md
Part of the SYNCRO v2 rewrite. Epic: A — Contract foundation.
Context
SubscriptionData,EscrowAgreement,CardandPaymentChannelare stored directly ascontracttypestructs in persistent storage. Adding a field to any of them silently breaks deserialization of existing entries after an upgrade, andcontract-upgradehas no story for migrating state — only for swapping WASM.Scope
schema_version: u32field to every persisted struct and aStorageVersioninstance key per contract.migrate(from_version)entrypoint gated to admin/guardian, callable only once per version step.Acceptance criteria
migrate()that is idempotent and rejects out-of-order versions.contracts/DEPLOYMENT.mddocuments the migration procedure and the rollback constraint.Files / areas
contracts/contracts/*/src/lib.rs,contracts/contracts/contract-upgrade/src/lib.rs,contracts/DEPLOYMENT.mdPart of the SYNCRO v2 rewrite. Epic: A — Contract foundation.