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

preupgrade hook #128

@mafintosh

Description

@mafintosh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions