Skip to main content

Module db

Module db 

Source
Expand description

Opens the CLI’s database for mutating commands, seeds the built-in and user-catalog DCS/PLC templates, and runs the retention sweep. Read-only commands such as bhtune check use a separate connection that skips bootstrap and retention.

Functions§

open
Opens (creating if necessary) the database at path, running migrations, then upserts the built-in templates via bhtune_db::seed_builtin_templates so a fresh database is immediately usable without a separate setup step. If user_templates is Some (the caller found and parsed a user catalog file – see crate::config::load_user_templates), those templates are additionally upserted with TemplateOrigin::Catalog via bhtune_db::seed_templates. None means no user catalog file was found at all, which is not an error and simply skips this second seed pass – the common case, since most installs never create templates.toml.
open_demo
Opens the Demo database without running the Full-mode live-orphan recovery sweep.
open_read_only
Opens an existing database for inspection without creating directories, applying migrations, seeding templates, or running retention.