medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
469 stars 217 forks source link

Remove pre 3.x db migrations and protect `migration-log` doc from edits #9639

Open dianabarsan opened 1 week ago

dianabarsan commented 1 week ago

What feature do you want to improve? Database migrations are messy. Some of the early database migrations were so heavy, they took down deployments for days when they ran. They're also quite complex, can be destructive and are gatekept by a document migration-log. If a migration doesn't exist in this log, it will run the next time api starts. Editing the migration-log doc is not validated in any way, it's not protected by validate_doc_update, so deletes or edits can be extremely dangerous to a deployment.

Describe the improvement you'd like

  1. Make sure only admins can edit the migration log. And never allow it to be deleted. We can also make some specific rule about never removing a migration from being run.
  2. Remove migrations that were added before 3.x. These are the heaviest and most destructive. Nobody runs CHT 2.x any more, we don't support it. The migrations can be kept for historical reasons, but their code should never run over a database.

Describe alternatives you've considered Leave it as it is.