Skip to main content

systemprompt_database/
extension.rs

1//! Extension registration for the database crate's own schema.
2//!
3//! Every systemprompt extension that owns DDL registers itself through the
4//! `inventory` framework. The database crate registers its own bookkeeping
5//! tables (`extension_migrations`) and shared SQL helper functions so that
6//! they install before any downstream extension runs.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11use systemprompt_extension::prelude::*;
12
13#[derive(Debug, Clone, Copy, Default)]
14pub struct DatabaseExtension;
15
16impl Extension for DatabaseExtension {
17    fn metadata(&self) -> ExtensionMetadata {
18        ExtensionMetadata {
19            id: "database",
20            name: "Database",
21            version: env!("CARGO_PKG_VERSION"),
22        }
23    }
24
25    fn schemas(&self) -> Vec<SchemaDefinition> {
26        vec![
27            SchemaDefinition::new(
28                "extension_migrations",
29                include_str!("../schema/extension_migrations.sql"),
30            ),
31            SchemaDefinition::new("services", include_str!("../schema/services.sql"))
32                .with_required_columns(vec!["name".into(), "module_name".into(), "status".into()]),
33            SchemaDefinition::sql_only(include_str!("../schema/functions.sql")),
34        ]
35    }
36
37    fn migrations(&self) -> Vec<Migration> {
38        extension_migrations!()
39    }
40
41    fn dependencies(&self) -> Vec<&'static str> {
42        vec![]
43    }
44
45    fn priority(&self) -> u32 {
46        0
47    }
48}
49
50register_extension!(DatabaseExtension);