Skip to main content

Crate cratefield_adapter_sqlite

Crate cratefield_adapter_sqlite 

Source
Expand description

cratefield-adapter-sqlite: the Database port over rusqlite (bundled SQLite). Native only — never compiled to wasm. Used by every module test and viable for a single-node self-hosted deployment (ADR 0004).

A rusqlite::Connection is Send but !Sync; the harness requires Arc<dyn Database> to be Send + Sync, so the connection lives behind a mutex. This is connection guarding, not request state; the scoped clippy allow follows the policy documented in the workspace clippy.toml.

cratefield-adapter-sqlite — Every test runs on it.

cratefield-adapter-sqlite on crates.io cratefield-adapter-sqlite documentation MIT

§cratefield-adapter-sqlite

The Database port over rusqlite (bundled SQLite) for the Factory Zero harness. Native only — never compiled to wasm. Used by every module test and by cratefield-testing, and viable for a single-node self-hosted deployment (ADR 0004).

ⓘ
use cratefield_adapter_sqlite::SqliteDatabase;

let db = SqliteDatabase::in_memory()?;          // or ::open("venture.db")
db.apply_migrations("email-signup", &migrations)?; // tracked in harness_migrations
// ... through Arc<dyn Database> as usual
  • batch runs all statements in one transaction (atomic).
  • apply_migrations(module, &[SqlMigration]) is idempotent: each migration is tracked under <module>/<id> in a harness_migrations table and applied in its own transaction.
  • The rusqlite connection is !Sync, so it lives behind a mutex; this is connection guarding, not request state (see the workspace clippy.toml policy).

MIT. Built in the open for Cratefield, a Factory Zero venture.

Structs§

SqliteDatabase
An open SQLite database (file path or :memory:).