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
8use systemprompt_extension::prelude::*;
9
10#[derive(Debug, Clone, Copy, Default)]
11pub struct DatabaseExtension;
12
13impl Extension for DatabaseExtension {
14    fn metadata(&self) -> ExtensionMetadata {
15        ExtensionMetadata {
16            id: "database",
17            name: "Database",
18            version: env!("CARGO_PKG_VERSION"),
19        }
20    }
21
22    fn migration_weight(&self) -> u32 {
23        10
24    }
25
26    fn schemas(&self) -> Vec<SchemaDefinition> {
27        vec![
28            SchemaDefinition::inline(
29                "extension_migrations",
30                include_str!("../schema/extension_migrations.sql"),
31            ),
32            SchemaDefinition::inline("functions", include_str!("../schema/functions.sql")),
33        ]
34    }
35
36    fn dependencies(&self) -> Vec<&'static str> {
37        vec![]
38    }
39}
40
41register_extension!(DatabaseExtension);