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

Build a generic database upgrade mechanism #73

Open
bgrieder opened this issue Oct 26, 2023 · 0 comments
Open

Build a generic database upgrade mechanism #73

bgrieder opened this issue Oct 26, 2023 · 0 comments

Comments

@bgrieder
Copy link
Contributor

A generic database upgrade mechanism on startup should be built.

This involves:

  • Creating a context table with a single record holding the last version of the software run (when the table is not present, assume the version run is the one before the version implementing the change)
  • On server startup:
    • the server checks if the software version is greater than the last version run
    • if no, it simply starts
    • if yes,
      • it looks for all upgrades to apply in order from the last version run to this version (this is done using a static function hardcoding the upgrade functions to call for each version)
      • if there is any to run, it sets an upgrading flag on the db state field in the context table
      • it runs all the upgrades in order
      • it sets the flag from upgrading to ready
  • On every call to the DB, a check must be performed on the db state field to check if the DB is upgrading. If yes, calls should fail. Performance can be maintained using a secondary write-through cache of the context table

Upgrades should be programmed to resist being interrupted in the middle and resumed from start.

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

No branches or pull requests

1 participant