Available on crate feature
postgres only.Expand description
PostgreSQL session persistence with explicit schema management.
§Schema Management
This module separates schema management from data access, allowing flexible deployment:
use claude_agent::session::{PostgresPersistence, PostgresSchema, PostgresConfig};
// Option 1: Auto-migrate (development/simple deployments)
let persistence = PostgresPersistence::connect_and_migrate("postgres://...").await?;
// Option 2: Connect only, manage schema externally (production)
let persistence = PostgresPersistence::connect("postgres://...").await?;
// Option 3: Export SQL for external migration tools (Flyway, Diesel, etc.)
let sql = PostgresSchema::sql(&PostgresConfig::default());
println!("{}", sql);
// Option 4: Verify schema is correct
let issues = persistence.verify_schema().await?;
if !issues.is_empty() {
for issue in &issues {
eprintln!("Schema issue: {:?}", issue);
}
}Structs§
- PgPool
Config - Connection pool configuration for PostgreSQL.
- Postgres
Config - PostgreSQL persistence configuration.
- Postgres
Persistence - PostgreSQL session persistence.
- Postgres
Schema - Schema manager for PostgreSQL persistence.
Enums§
- Schema
Issue - Schema issue found during verification.