pub fn ensure_db_ready(paths: &AppPaths) -> Result<(), AppError>Expand description
Ensures the database file exists and the schema is at the current version.
Behavior:
- DB does not exist: creates the file, applies init PRAGMAs, runs all migrations,
sets
PRAGMA user_version, and populatesschema_metawith default values. Emitstracing::info!on creation. - DB exists with
user_versionbelowSCHEMA_USER_VERSION: runs the remaining migrations and updatesuser_version. Emitstracing::warn!on auto-migration. - DB exists with
user_versionequal toSCHEMA_USER_VERSION: no-op.
This helper unifies the auto-init contract across CRUD handlers so users can run
any subcommand on a fresh directory without invoking init first. Idempotent
and safe to call before every handler that needs a ready database.