Migrations
DearDiary.Migration — Type
MigrationA 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 theschema_migrationstracking 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 throughDBInterface.execute, matching how the rest of the repository talks to the database.
DearDiary.apply_migrations — Function
apply_migrations(db::DuckDB.DB)::NothingApply 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.
DearDiary.applied_versions — Function
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.
DearDiary.MIGRATIONS — Constant
MIGRATIONSThe 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.