Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut migrations #26

Open
hashedone opened this issue Aug 25, 2022 · 0 comments
Open

Shortcut migrations #26

hashedone opened this issue Aug 25, 2022 · 0 comments
Labels

Comments

@hashedone
Copy link
Collaborator

Improvement of #25

It should be always correct to migrate from 1.0 to 1.2 version of the contract by applying migrations one by one: 1.0 -> 1.1 -> 1.2.
However it may be a case, where it is strongly inefficient and we want to support a migration from 1.1, but have a completely separate implementation of migration from 1.0. Example like this:

struct Contract { /* ... */ }

#[contract]
impl Contract {
  #[msg(migrate, from = 1.0, to = 1.2)]
  fn migrate1_0(&self, ctx: MigrationCtx, /* ... */)  -> Result<Respons, ContractError> {
    /* ... */
  }

  #[msg(migrate, from = 1.1, to = 1.2)]
  fn migrate1_1(&self, ctx: MigrationCtx, /* ... */)  -> Result<Respons, ContractError> {
    /* ... */
  }
}

There are two migrations to the same version but from different ones. Sylvia should be able to figure that out and still generate all the migrations for all versions. There always should be only one path to migrate from a specific version, as in this case migration from 1.0 to 1.1 is not needed anymore for our contract. Having obsolete migrations should report a warning as they would never be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant