Page MenuHomeSoftware Heritage

Add a 'swh db upgrade' cli
Closed, MigratedEdits Locked

Description

This wil need to move migration scripts to swh/<mod>/sql/upgrades and have a wrapper script in swh.core.db that:

  1. check the current dbversion;
  2. check the latest dbversion;
  3. run the migrations in between

Event Timeline

douardda created this task.

The problem with step 2. is that we do not have an API to declare the latest version, something that should come with swh.core.db is suppose.

To help a bit, here is the plan:

  • add helper tools in swh.core.db based datastores so that (postgresql) db version and migrations can be managed in swh.core directly:
    • make all swh datastore packages provide a get_datastore factory function in the top level namespace; this is typically just an alias for get_storage, get_scheduler, etc.
    • make datastore objects (the object instanciated by the get_datastore factory function) provide a get_current_version() method
    • move migration sql scripts in the package (along with the initialization sal scripts).

then we should have everything we need to make swh.core.db able to manage the db versionning:

  • make 'swh db init' create the dbversion table (as well as a new dbmodule table to store the actual swh package behind this database),
  • add a `swh db upgrade' executing the migration scripts from "current db version' to "current datastore code version"
douardda claimed this task.