Available on crate feature
postgres only.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
| Version | Description |
|---|---|
| 1 | Initial schema — tasks table with indexes on context_id and state |
| 2 | Add composite index on (context_id, state) for combined filter queries |
| 3 | Add (updated_at DESC, id DESC) index for list ordering |
| 4 | Add idempotency_keys — the index client-supplied send keys are claimed in |
| 5 | Add task_events — the per-task log of what the agent emitted |
| 6 | Add CHECK (seq > 0) to task_events |
| 7 | Add applied_seq to tasks — the log position each write stores |
| 8 | Add a2a_task_claims — which replica runs each task’s current turn |
| 9 | Add the triggers and functions that keep a replica of an earlier release off a task a newer replica runs |
This table listed 1 and 2 while five existed. BUILTIN_PG_MIGRATIONS is
the list; the test below fails if the two stop agreeing on how many there
are.
§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.
- PgMigration
Runner - Runs schema migrations against a
PostgreSQLdatabase.
Statics§
- BUILTIN_
PG_ MIGRATIONS - Built-in migrations for the
PostgresTaskStoreschema.