Migrations

DearDiary.MigrationType
Migration

A forward-only schema migration applied by apply_migrations.

Fields

  • version::Int: Monotonically increasing version number. Determines application order and serves as the primary key in the schema_migrations tracking table. Once committed, do not reuse a version number.
  • 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 the database.
source
DearDiary.apply_migrationsFunction
apply_migrations(db::DuckDB.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: every release moves the schema forward, never backward.

source
DearDiary.applied_versionsFunction
applied_versions(db::DuckDB.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
DearDiary.MIGRATIONSConstant
MIGRATIONS

The ordered registry of every Migration that ships with DearDiary. New schema changes must append a new entry here (and add a numbered file under migrations/). Never edit a previously-released migration in place: existing databases have already applied it and will not re-run it.

source