Skip to main content

seed_templates

Function seed_templates 

Source
pub async fn seed_templates(
    pool: &SqlitePool,
    templates: Vec<DcsTemplate>,
    origin: TemplateOrigin,
    now: DateTime<Utc>,
) -> DbResult<Vec<SeedResult>>
Expand description

Upserts every template in templates into dcs_templates, all attributed to origin.

Safe to call on every startup: inserts any missing template, brings existing rows that already carry origin in line with the current definition, and never touches a row whose name collides with one being seeded but which carries a different origin — that row belongs to a different catalog (or a user), not this seed pass.

The runtime uses this for a user-supplied catalog with TemplateOrigin::Catalog; seed_builtin_templates uses the same upsert logic for [bhtune_core::built_in_templates] with TemplateOrigin::Builtin.