Expand description
Database schema versioning: forward-only, with a snapshot before a migration.
The version lives in SQLite’s user_version pragma. A build knows one version
(SCHEMA_VERSION). On open:
- a file whose version is NEWER than the build’s is refused with a clear error (a downgrade would run old code against tables it does not understand; restore the snapshot instead);
- a file with data and an OLDER version (0 = written before versioning, i.e. 0.4.x) is first copied, then migrated, then marked with the new version. The copy is the downgrade path.
Environment: M4A_DB_SNAPSHOT=off disables the copy; M4A_DB_SNAPSHOT_DIR puts it in a
directory (default: next to the database file). The copy is named
<file>.pre-schema-v<new>-<unix seconds>.
History: 1 = up to 0.4.x (no marker); 2 = 0.5.0 (presence, remote media cache, login tokens).