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 schemas(&self) -> Vec<SchemaDefinition> {
23 vec![
24 SchemaDefinition::new(
25 "extension_migrations",
26 include_str!("../schema/extension_migrations.sql"),
27 ),
28 SchemaDefinition::new("functions", include_str!("../schema/functions.sql")),
29 ]
30 }
31
32 fn dependencies(&self) -> Vec<&'static str> {
33 vec![]
34 }
35
36 fn priority(&self) -> u32 {
37 // No extension declares `database` as a dependency, so install order is
38 // decided purely by priority among roots; 0 keeps the shared helper
39 // functions and `extension_migrations` ahead of every other extension.
40 0
41 }
42}
43
44register_extension!(DatabaseExtension);