Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

preupgrade hook #128

Open
mafintosh opened this issue Aug 11, 2022 · 0 comments
Open

preupgrade hook #128

mafintosh opened this issue Aug 11, 2022 · 0 comments

Comments

@mafintosh
Copy link
Collaborator

I think we need a "preupgrade" hook that, if set, runs when the user calls update, allowing them to ensure certain conditions around the upgrade. this would just be a view, like non-sparse mode (infact non-sparse could be implemented as a hook).

For example:

const s = core.session({
  preupgrade (latest) { // where latest is a session that is on the latest length
    await latest.get(latest.length - 1) // always ensure the latest block is there
    return latest.length // can optionally return the length we're upgraded to                                     
  }
})

// calls above
await s.update()

We might wanna allow simple naming of the hooks also so users can define a couple, but let's defer that to after we have one working. The pointer a preupgrade session is on should also be stored in the oplog, so we can checkout the current existing one on restart

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

Successfully merging a pull request may close this issue.

1 participant