Skip to content

Commit

Permalink
improve migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tsilva-figure committed Sep 18, 2023
1 parent 3fe33dc commit f05d986
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ pub fn migrate(
let contract_info = get_contract_version(deps.storage)?;

match contract_info.version.as_str() {
"2.3.0" => {}
"2.3.0" | "2.3.1" => {
let mut state: State = singleton_read(deps.storage, CONFIG_KEY).load()?;

state.subscription_code_id = migrate_msg.subscription_code_id;

config(deps.storage).save(&state)?;
}
"2.2.0" | "2.2.1" => {
let old_state: StateV2_2_0 = singleton_read(deps.storage, CONFIG_KEY).load()?;
let required_capital_attributes =
Expand Down Expand Up @@ -63,7 +69,10 @@ pub fn migrate(
config(deps.storage).save(&new_state)?;
}
_ => {
return contract_error("existing contract version not supported for migration to 2.3.0")
return contract_error(&format!(
"existing contract version not supported for migration to {}",
contract_info.version
));
}
};

Expand Down

0 comments on commit f05d986

Please sign in to comment.