DB Migration Planning Documentation - conrad-blucher-institute/semaphore GitHub Wiki

Database Migration Algorithm

image

UML Diagram of Database Migration Interface

image

Proposed Tasks (Before First Meeting)

  • Create the Interface Class
  • Create file for noting the target version of the database
    • could be a json file with a description of the changes -Adding table to database to note the current version of the database
    • (we probably want to use this as our first test case for updating and rollback!)
    • Name of Table: deploy_current_database_version
    • Columns: Id column, version_number column, deployed_on timestamp, description_of_version_changes (read from json)
  • Organize Files for Database Migration
    • Make a directory within tools for the database version folders to be stored and move the static version file inside of it as well
  • Edit init_db.py
    • Init_db already checks if the database exists and if it doesn’t instantiates it.
    • person who is doing this can also brainstorm new names for the file (maybe migrate_db.py?)
    • Add the logic for checking the database version.
      • Read current version from database
      • Read the target version from the file.
      • Update or Rollback as needed, updating the version file as you go.
      • Stop when the correct version is reached.
  • Finish Script To Add API Account
    • Parameterization of query
    • Implementing both methods in interface

Notes (form first meeting discussing Database Migration)

  • absolutely use transactions for the update methods (so that things that don't work will automatically not make it to the database)
  • rollback is just for purposeful user rollback not automatic rollback if update method fails
  • for versions of the database major.minor
    • major = adding tables or editing scheme
    • minor = adding data/users/anything else