soma_schema/lib.rs
1//! # soma-schema
2//!
3//! A standalone Postgres migration tool — plain SQL files with `UP`/`DOWN` sections,
4//! manifest-driven ordering, SHA-256 checksum drift detection, and advisory-lock safety
5//! to prevent concurrent `up`/`down` runs.
6//!
7//! **Differentiators:** (1) manifest-first ordering (not filename-lexical) for FK-safe
8//! rollback; (2) checksum on the full raw file (UP + DOWN) so even editing the DOWN
9//! section of an applied migration is caught; (3) apply + track in a single transaction
10//! (no split state on crash); (4) advisory lock scoped to the whole `up`/`down` call
11//! (not per-migration).
12//!
13//! ## Quick start
14//!
15//! ```no_run
16//! # use soma_schema::{Migrator, PostgresConfig, PostgresDriver};
17//! # async fn run() -> soma_schema::Result<()> {
18//! let pool = sqlx::PgPool::connect("postgres://localhost/mydb").await?;
19//! let config = PostgresConfig {
20//! schema: Some("app".into()),
21//! ..Default::default()
22//! };
23//! let driver = PostgresDriver::new(pool, config)?;
24//! let migrator = Migrator::from_root("migrations");
25//! migrator.up(&driver).await?;
26//! # Ok(())
27//! # }
28//! ```
29
30pub mod agent_rules;
31pub mod discovery;
32pub mod driver;
33pub mod error;
34pub mod manifest;
35pub mod migration;
36pub mod migrator;
37pub mod postgres;
38
39#[cfg(feature = "explorer")]
40pub mod explorer;
41
42pub use agent_rules::{install_skill, write_rules, RulesTarget};
43pub use discovery::discover;
44pub use driver::{AppliedMigration, LockGuard, MigrationDriver};
45pub use error::{Error, Result};
46pub use migration::{Migration, SetupFile};
47pub use migrator::{MigrationStatus, Migrator, PendingMigration};
48pub use postgres::{PostgresConfig, PostgresDriver};
49
50// Re-export so consumers can write `soma_schema::include_dir::include_dir!(...)` without
51// a separate version-matched include_dir dependency.
52pub use include_dir;
53
54#[cfg(feature = "explorer")]
55pub use explorer::{build_json, render_html};