Skip to content

Database and migrations

Michael Yingbull edited this page Sep 28, 2026 · 6 revisions

Database and migrations

Home / Technical documentation / Developing CARLOS

A schema change can outlive the code change that introduced it. Begin by finding the existing table, its callers, and any province-specific behavior before creating a migration. Think through old records, new installs, and upgrades from an earlier release; each path needs to end in a usable database.

Understand the data before changing it

Look up the relevant model and DAO in the source tree, then inspect the matching schema migration. Structured chart data and uploaded documents are stored differently; a database change alone may not cover files or generated PDFs. Write down the records a clinic task reads and writes before adding a column or changing a query.

CARLOS uses Flyway migrations. Add a new migration following the numbering and province rules in database schema management. A migration already published in a release is checksum-frozen. Do not edit it; add a new migration for the correction. Test a fresh database and an upgrade from the previous supported state, including data already present. On a package installation, sudo carlos-ctl db-info and db-validate report schema state; db-migrate changes it and requires a backup.

SCREENSHOT NEEDED — DEV-DB: Capture an editor view of the release/2026.08 migration directories and one short migration header, with a synthetic db-info result. Show common and province-specific paths without database credentials.

A failed migration needs investigation of the exact error and a recovery plan. db-repair changes migration history; it is not a general fix for data that did not migrate.

Test the migration with representative fictional data and inspect the result, not only the process exit code. Include a rollback or repair plan for a partially applied change. Reviewers should be able to see why the new field or index is needed and how older data will behave.

Related pages

Testing and quality · Upgrades and migration

CARLOS documentation

All topics · Get help

Using CARLOS

Start here · Clinic workflows

Getting started and everyday reference
Office staff
Clinical staff and doctors
Clinic managers and administrators

Technical documentation

Technical overview · Reference

Running CARLOS

Install and configure
Maintain and troubleshoot

Developing CARLOS

Code, interfaces, and tests
Contribute and maintain releases

For everyone

Write and maintain the documentation

Clone this wiki locally