Skip to content

feat: Reloadable db

Fox Piacenti requested to merge fox/reloadable-db into master

This Merge request adds the ability to drop the current database and replace it with a saved one. It also adds the ability to generate historical data based on a given recurrence ID.

It also addresses several pieces of technical debt, including formatting commands that hadn't been run in too long, issues with the build, and upgrading of several dependencies.

Supporting information

  • Jira ticket: url
  • GitLab issue: url

Testing instructions

Step by step procedure

  1. make
  2. Log in with admin@example.com admin
  3. Find the recurrence ID with the Django admin. Edit the interval of the recurrence to be every week or two, rather than every few minutes.
  4. make shell
  5. ./manage.py seed_historical_data --recurrence=recurrence_id_goes_here --intervals=10
  6. Run the reports to verify the historical data has been created
  7. Perform a database dump of the PostgreSQL database and store it in a file.
  8. docker compose down to destroy the whole setup.
  9. make to bring a fresh one
  10. make shell
  11. ./manage.py replace_db < sql_file_name.sql
  12. Verify that the old data is restored.

Author notes and concerns

When I started working on this, I got most of the way to where we are now, feature-wise. However, when I picked it back up to run tests, I found CI had broken. I started pulling on the thread of fixing it and cleaning up along the way, and found myself cleaning up a recursive amount of technical debt that had piled up. In the process, the Python version, the Python package versions, and the OS have been upgraded. Although Ubuntu 24.04 was released this month, I have not upgraded to it because it seems to have some pretty significant changes for the build (including the addition of a default user) which make our existing build fail, and the existing LTS will work for a few years yet.

I suspect this isn't the whole of what I'll need to accomplish to completely close the tickets this is for, but because it has a large amount of changes across the codebase, we should go ahead and review it then merge so nothing else is held up on it, so long as this part of the work passes review and works well.

Edited by Fox Piacenti

Merge request reports