Module persistence_postgres

Module persistence_postgres 

Source
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§

PgPoolConfig
Connection pool configuration for PostgreSQL.
PostgresConfig
PostgreSQL persistence configuration.
PostgresPersistence
PostgreSQL session persistence.
PostgresSchema
Schema manager for PostgreSQL persistence.

Enums§

SchemaIssue
Schema issue found during verification.