Skip to main content

Module pg_migration

Module pg_migration 

Source
Expand description

Schema versioning and migration support for PostgresTaskStore.

This module provides a lightweight, forward-only migration runner that tracks applied schema versions in a schema_versions table. Migrations are defined as plain SQL strings and are executed inside transactions for atomicity.

§Built-in migrations

VersionDescription
1Initial schema — tasks table with indexes on context_id and state
2Add composite index on (context_id, state) for combined filter queries

§Example

use a2a_protocol_server::store::pg_migration::PgMigrationRunner;
use sqlx::postgres::PgPoolOptions;

let pool = PgPoolOptions::new()
    .connect("postgres://user:pass@localhost/a2a")
    .await?;

let runner = PgMigrationRunner::new(pool);
let applied = runner.run_pending().await?;
println!("Applied migrations: {applied:?}");

Structs§

PgMigration
A single schema migration.
PgMigrationRunner
Runs schema migrations against a PostgreSQL database.

Statics§

BUILTIN_PG_MIGRATIONS
Built-in migrations for the PostgresTaskStore schema.