Skip to main content

systemprompt_runtime/
installation.rs

1//! Module schema/seed installation helpers.
2//!
3//! These wrap the lower-level installers in `systemprompt-database` and
4//! attach an [`AppContext`] when the caller does not already have one.
5
6use crate::AppContext;
7use crate::error::RuntimeResult;
8use systemprompt_database::{
9    DatabaseProvider, install_module_schemas_from_source, install_module_seeds_from_path,
10};
11use systemprompt_models::modules::Module;
12
13pub async fn install_module(module: &Module) -> RuntimeResult<()> {
14    let app_context = AppContext::new().await?;
15    install_module_with_db(module, app_context.db_pool().as_ref()).await
16}
17
18pub async fn install_module_with_db(
19    module: &Module,
20    db: &dyn DatabaseProvider,
21) -> RuntimeResult<()> {
22    install_module_schemas_from_source(module, db).await?;
23    install_module_seeds_from_path(module, db).await?;
24    Ok(())
25}