SeaORM
SeaORM's DatabaseConnection as a store, with the SQLite pool and migration specifics.
ulo-db-seaorm binds SeaORM 2.0's DatabaseConnection for Postgres, MySQL and SQLite. It needs Rust 1.94.
[dependencies]
ulo-db-seaorm = { version = "=0.1.0-alpha.3", features = ["postgres"] }
sea-orm = "2.0"The features are postgres, mysql, sqlite and tls, the last on by default and shared with ulo-db-sqlx. With no engine feature the crate accepts no URL. The application depends on sea-orm itself for entities and queries, with the SQLx the build already holds.
use ulo_db_seaorm::{SeaOrmMigrations, SeaOrmModule};
m.import(SeaOrmModule::from_config(&config, "database").migrate(SeaOrmMigrations::<Migrator>::new()));Options
url, max_connections, min_connections and acquire_timeout_secs, with the meanings they have for SQLx.
SeaORM's Database::connect writes the whole URL, password included, into its parse errors. The store therefore validates with SQLx's option parser before SeaORM sees the URL, after the scheme check it shares with ulo-db-sqlx. A malformed URL never reaches Database::connect.
The pool is lazy on all three engines, so the start waits on the ping unless the module is .lazy(). An attempt's bound should exceed acquire_timeout_secs, which SQLx's 30 second default applies on Postgres and MySQL when unset.
SQLite
SeaORM's own SQLite connector queries sqlite_version() while connecting, so it would connect inside create. The store builds the pool through ulo-db-sqlx's lazy pool instead and wraps it with SqlxSqliteConnector::from_sqlx_sqlite_pool.
Three consequences follow:
- Of SeaORM's
ConnectOptions, onlymax_connections,min_connectionsandacquire_timeout_secsapply.max_connectionsis 1 when unset, as SeaORM's connector defaults it, andacquire_timeout_secsis 5. - The wrapped path skips SeaORM's connect-time version check. The store's ping makes that check instead and refuses a SQLite older than 3.35, which
RETURNINGneeds, as a permanent failure. An old SQLite fails the start, or the first health check under.lazy(). - Statement logging follows SQLx's defaults.
Migrations
SeaOrmMigrations::<Migrator>::new(), where Migrator is your own sea-orm-migration migrator type, wraps a sea-orm-migration Migrator, and its up runs under ulo-db's lock. sea-orm-migration takes no lock of its own, so without the lock two replicas apply a migration body at once.
TLS and moved connections
No test exercises a TLS connection through this store. SeaORM holds an SQLx pool, so the dropped-off-the-runtime caveat applies to its pooled connections.