Cesar Rodas ee20cc1f2b Remove the vestigial UserData type and the orphaned withdraw saga step 11 ساعت پیش
..
src ee20cc1f2b Remove the vestigial UserData type and the orphaned withdraw saga step 11 ساعت پیش
tests ee20cc1f2b Remove the vestigial UserData type and the orphaned withdraw saga step 11 ساعت پیش
Cargo.toml 2015894107 Store SQL columns as hex/JSON text for auditability 1 هفته پیش
README.md 2015894107 Store SQL columns as hex/JSON text for auditability 1 هفته پیش

README.md

kuatia-storage-sql

SQL-backed Store implementation for the kuatia ledger.

Uses sqlx::Any for database-agnostic queries. Enable features to select the backend:

[dependencies]
kuatia-storage-sql = { features = ["sqlite"] }   # or "postgres"

Backends

Feature Backend Status
sqlite (default) SQLite via sqlx Conformance tests pass
postgres PostgreSQL via sqlx Portable DDL/queries; needs a running instance to test

A single portable schema in src/migrations/001_init.sql serves both backends. Applied migrations are tracked in a _migrations table, so migrate() is idempotent. Upserts use portable ON CONFLICT … DO UPDATE, and all ids are generated in Rust (no AUTOINCREMENT/SERIAL).

Every column is a text type: no opaque binary is stored. Content-addressed ids (and the opaque saga blob) are kept as lower-case hex TEXT, and structured payloads as their JSON TEXT serialization, so any row is readable in a plain SQL client for auditing. The JSON is never queried into.

Usage

use kuatia_storage_sql::SqlStore;

let pool = sqlx::any::AnyPoolOptions::new()
    .connect("sqlite::memory:").await?;
let store = SqlStore::new(pool);
store.migrate().await?;

Schema

Tables: accounts, postings, transfers, transfer_accounts, sagas, events, books. Migrations run via store.migrate().