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

cratesfyi database upgrade command #303

Closed
QuietMisdreavus opened this issue Feb 15, 2019 · 0 comments
Closed

cratesfyi database upgrade command #303

QuietMisdreavus opened this issue Feb 15, 2019 · 0 comments

Comments

@QuietMisdreavus
Copy link
Member

This issue is mainly to collect design thoughts before i implement the feature.

The problem at hand is that there's currently no way to orchestrate updating the database schema if we try to change it. I'd like to tweak the database as part of #301, so if i can get this out of the way at the same time, all the better!

Current ideas:

  • we already have a database_version config value being stored - it's added and set to 1 when database init is run
  • a database upgrade command could inspect this value, then execute a series of queries that incrementally apply a change from one version to the next
  • if the config table is missing when database upgrade is run, fail the command and suggest running database init instead
  • if the config table is present but the database_version entry is missing, do nothing and exit with failure
  • if the database version matches the latest version, do nothing and exit with success
    • (this way, we can just put cratesfyi database upgrade in our deploy script and run it every time 😉)
  • if the database version is greater than the current version, do nothing and exit with failure
  • if the database version is less than the current version, load up the changes to make and apply them one-by-one, then update the version in the database

One question that's worth noting is whether we want to support downgrading? It doesn't seem too useful to keep around, but could come in handy.

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