iet-db
core contracts official
Defines database lifecycle and reviewed-migration contracts without driver SQL types.
CoreFeaturesIntegrationsStacksTooling
Used byiet-db-timescale
iet-dbcontractsDatabase contractsDepends oniet-corecontract
How to use it
iet-db defines the database lifecycle — Database: SessionFactory with close() — and the reviewed-migration contract MigrationRunner with status, apply, and rollback_to. Drivers implement it; only trusted, reviewed SQL files are executed through this port.
// tools/iet-db-cli/src/main.rs
use ;
let migrations =
load.await?;
match cli.command
database.close.await;
MigrationStatus::pending()counts entries whereapplied == falsewithout iterating yourself.rollback_to(0)removes all history; a nonzero target must be an already-applied version.
How it works
MigrationRunner::status returns a MigrationStatus of MigrationEntry rows, while apply and rollback_to advance the reviewed schema; Database::close releases the driver after the command finishes.
sequenceDiagram participant C as "CLI caller" participant R as "MigrationRunner" participant S as "MigrationStatus" C->>R: "status" R-->>S: "entries" S-->>C: "MigrationEntry list" C->>R: "apply" C->>R: "rollback_to target" participant D as "Database" C->>D: "close"
Core contract
This page is the crate reference. For the framework-wide runtime and trait model, read Architecture.
What it implements
- Defines the traits other crates implement:
Database,MigrationRunner.
What's inside
Modules
src/lib.rs
Public API
(root)
- trait
Database
- struct
MigrationEntry - struct
MigrationStatus pub fn pending(&self) -> usize- trait
MigrationRunner— Trusted, reviewed SQL files; never execute request-supplied SQL here.
Depends on
Used by
In this repository
examples/htmx-starterexamples/skills-only-app-task-tracker
Source: crates/core/iet-db