Skip to main content

bhtune_db/models/
mod.rs

1//! Row types mirroring the tables in `migrations/`.
2//!
3//! These are deliberately *typed*, not raw-column, shapes: wherever a table's columns are a
4//! clean 1:1 match for an existing `bhtune-core` type (`DcsTemplate`, `LoopTags`,
5//! `LoopConfig`, `Tick` + `MrftState`), the row struct holds that type directly rather than
6//! re-declaring its fields — one less place for the two to drift apart. Where a table
7//! combines fields from two `bhtune-core` types that both carry their own overlapping field
8//! (`TuningResult`/`PidParameters` both carry `response_level`; `InitialReadings`/`PvRange`
9//! don't nest cleanly with the extra `controller_direction` column), the row struct is flat
10//! instead, matching the table exactly and avoiding a redundant, only-sometimes-consistent
11//! duplicate field.
12//!
13//! [`DemoSessionRow`], [`DcsTemplateRow`], and
14//! [`TuneRunRow`]/[`TuneSampleRow`]/[`TuneResultRow`]/
15//! [`TuneMvActuationRow`]/[`TuneWriteRow`] have full repository methods (insert, lifecycle
16//! transitions, filtering, pagination). [`LoopRow`] deliberately has no repository methods:
17//! full CRUD for saved loops (list/update/delete) is separate from run history, which is about
18//! *runs*, not the loops they reference. Tests construct `loops` rows with raw SQL (see
19//! `tests/schema.rs`'s `seed_loop` helper) purely as foreign-key setup.
20//!
21//! [`TuneRunRow::list`]/[`TuneRunRow::count`] build their `WHERE` clause dynamically with
22//! `sqlx::QueryBuilder`, since [`TuneRunFilter`]'s fields are all optional and the set of
23//! active conditions varies per call — a fixed `query!` string can't express that, and
24//! `bhtune-db` uses runtime `query`/`query_as` throughout anyway (see `Cargo.toml`), so this
25//! doesn't introduce a new query style, just the first dynamic one.
26
27mod dcs_templates;
28mod demo_sessions;
29mod live_ownership;
30mod loops;
31mod settings;
32mod tune_mv_actuations;
33mod tune_results;
34mod tune_runs;
35mod tune_samples;
36mod tune_writes;
37
38pub use dcs_templates::*;
39pub use demo_sessions::*;
40pub use live_ownership::*;
41pub use loops::*;
42pub use settings::*;
43pub use tune_mv_actuations::*;
44pub use tune_results::*;
45pub use tune_runs::*;
46pub use tune_samples::*;
47pub use tune_writes::*;