Migrations

DearDiary.MigrationType
Migration

A forward-only schema migration applied by apply_migrations.

Fields

  • version::Int: Monotonically increasing version number. Determines application order and is the primary key in the schema_migrations tracking table — once a version is committed, do not reuse it.
  • name::String: Short human-readable identifier (snake_case). Logged on application and stored alongside the version for debugging.
  • statements::Vector{String}: SQL statements applied in order. Each statement runs through DBInterface.execute, matching how the rest of the repository talks to SQLite.
source
DearDiary.apply_migrationsFunction
apply_migrations(db::SQLite.DB)::Nothing

Apply every Migration in MIGRATIONS whose version is not yet recorded in schema_migrations, in ascending order. Each migration's statements run sequentially via DBInterface.execute; the version is stamped into schema_migrations only after every statement succeeds, so a crash mid-migration leaves the registry untouched and the migration is retried on next startup.

Warning

Migrations are forward-only. There is no rollback story — the contract is "every release moves the schema forward, never backward."

source
DearDiary.applied_versionsFunction
applied_versions(db::SQLite.DB)::Set{Int}

Return the set of migration versions already recorded in schema_migrations. Creates the tracking table on first call so a freshly-opened database needs no special bootstrap.

source