PostgreSQL storage adapter for Jido agent checkpoints and thread journals. Provides durable, ACID-compliant persistence that survives restarts and deployments.
Add jido_storage_ecto to your list of dependencies in mix.exs:
def deps do
[
{:jido_storage_ecto, "~> 0.1.0"}
]
endmix ecto.gen.migration add_jido_storagedefmodule MyApp.Repo.Migrations.AddJidoStorage do
use Ecto.Migration
def up, do: Jido.Storage.Ecto.Migration.up()
def down, do: Jido.Storage.Ecto.Migration.down()
endmix ecto.migratedefmodule MyApp.Jido do
use Jido,
otp_app: :my_app,
storage: {Jido.Storage.Ecto, repo: MyApp.Repo}
endThat's it. hibernate/1, thaw/2, and InstanceManager all work automatically.
| Option | Default | Description |
|---|---|---|
:repo |
(required) | Your Ecto.Repo module |
:prefix |
"public" |
PostgreSQL schema for table isolation |
:format |
:json |
:json (queryable, human-readable) or :binary (lossless) |
Stores data as jsonb. Queryable and human-readable in the database.
Trade-off: Atom keys are restored on read via String.to_existing_atom/1
(safe). Atom values become strings — handle this in your restore/2 callback.
storage: {Jido.Storage.Ecto, repo: MyApp.Repo, format: :json}Stores data via :erlang.term_to_binary as bytea. Lossless round-trip —
atoms, tuples, and structs are preserved exactly. Decoded with the [:safe]
flag to prevent atom table exhaustion.
storage: {Jido.Storage.Ecto, repo: MyApp.Repo, format: :binary}For multi-tenant or namespaced deployments, use the :prefix option. This maps
to a PostgreSQL schema.
# Migration
def up, do: Jido.Storage.Ecto.Migration.up(prefix: "tenant_1")
def down, do: Jido.Storage.Ecto.Migration.down(prefix: "tenant_1")
# Configuration
storage: {Jido.Storage.Ecto, repo: MyApp.Repo, prefix: "tenant_1"}The migration creates three tables (within your configured prefix/schema):
| Table | Purpose |
|---|---|
jido_storage_checkpoints |
Key-value store for agent state snapshots |
jido_storage_thread_entries |
Append-only journal for thread entries |
jido_storage_thread_meta |
Per-thread revision tracking and metadata |
Migrations are versioned (like Oban). As new versions are released, generate a new Ecto migration:
defmodule MyApp.Repo.Migrations.UpgradeJidoStorageToV2 do
use Ecto.Migration
def up, do: Jido.Storage.Ecto.Migration.up(version: 2)
def down, do: Jido.Storage.Ecto.Migration.down(version: 2)
endApache-2.0