Skip to content

Migration Fails with Missing Entry MigrationData When Using Custom Migration Data name #519

@donghua-wang

Description

@donghua-wang

Summary

When testing the upgradeable contract example on Stellar testnet, the migration step fails with:
error: Missing Entry MigrationData

This happens only when the migration data struct is not literally named MigrationData, even though the example code suggests that the struct name should not matter.

Steps to Reproduce

Using the example upgradeable contracts:

#!/bin/bash
# Build and deploy V1 contract
cargo build --release --target wasm32-unknown-unknown -p upgradeable-v1-example
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/upgradeable_v1_example.wasm \
  --source alice --network testnet --alias upgradeable_v1 -- --admin $ALICE_ADDRESS

# Build and upload V2 contract
cargo build --release --target wasm32-unknown-unknown -p upgradeable-v2-example
V2_HASH=$(stellar contract upload \
  --wasm target/wasm32-unknown-unknown/release/upgradeable_v2_example.wasm \
  --source alice --network testnet)

# Upgrade V1 to V2
stellar contract invoke --id upgradeable_v1 --source alice --network testnet --send yes \
  -- upgrade --new_wasm_hash $V2_HASH --operator $ALICE_ADDRESS

# Attempt migration (THIS FAILS)
stellar contract invoke --id upgradeable_v1 --source alice --network testnet --send yes \
  -- migrate --migration_data '{"num1": 1000, "num2": 2000}' --operator $ALICE_ADDRESS

Actual Result:

❌ error: Missing Entry MigrationData

Additional Observations

If I rename my migration data struct exactly to MigrationData, the migration succeeds.

mod newtypes{
    use soroban_sdk::contracttype;

    #[contracttype]
    pub struct MigrationData {
        pub num1: u32,
        pub num2: u32,
    }
}

use newtypes::MigrationData as Data;

If I use any other struct name (e.g., MyMigrationData), the migration fails with the above error.

The example code in the repository indicates that struct naming should not be important for migration, but this does not match observed behavior on testnet.

Questions

Is this a bug in the example or in the underlying CLI/runtime?

Is the struct name MigrationData currently hard-coded or required in some part of the upgrade flow?

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions