rustauth-deadpool-postgres
Pooled Postgres database adapter for RustAuth.
What It Is
rustauth-deadpool-postgres is the recommended Postgres adapter when you want
pooling without taking a SQLx dependency. It uses deadpool-postgres for pool
management and reuses RustAuth's shared Postgres SQL planning.
Naming
RustAuth storage backends share one vocabulary:
| Type | Role |
|---|---|
DeadpoolPostgresAdapter |
DbAdapter implementation |
DeadpoolPostgresStores |
Adapter + SQL-backed rate-limit store sharing one pool |
DeadpoolPostgresStoresBuilder or DeadpoolPostgresStores::builder() |
Configure URL, schema, pool size, TLS, and validation |
apply_to_options |
Wire the rate-limit store into [RustAuthOptions] |
DeadpoolPostgresStoresBuilder is a type alias for DeadpoolPostgresBuilder.
What It Provides
DeadpoolPostgresStores: bundled adapter + SQL-backed rate-limit store sharing one pool (recommended entry point).DeadpoolPostgresAdapterandDeadpoolPostgresRateLimitStorefor BYO-pool setups.DeadpoolPostgresStoresBuilder(aliasDeadpoolPostgresBuilder) for connection URL, custom config, schema, pool size, TLS, and startup validation.- Additive migration planning and execution.
- Native Postgres arrays for RustAuth array fields.
Migration planning types live in rustauth_core::db.
Quick Start
use ;
use ;
use DeadpoolPostgresStores;
let schema = auth_schema?;
let stores = connect_with_schema_checked
.await?;
let auth = builder
.options
.adapter
.build?;
// Apply schema with `rustauth db migrate` before serving traffic.
# Ok::
Configure rustauth.toml with database.adapter = "deadpool-postgres", then run
rustauth db migrate --yes before starting the server. See
docs/database-migrations.md.
Builder
use DeadpoolPostgresStoresBuilder;
let adapter = new
.database_url
.schema
.checked
.max_size
.connect
.await?;
Use .checked(true) or validate_connection() when startup should fail fast if
the pool cannot check out a working database connection. Unchecked builds create
pools lazily and may report connection errors on the first operation.
Applications that already own a deadpool_postgres::Pool can pass it to
DeadpoolPostgresAdapter::new(pool) or with_schema(pool, schema).
Notes
- Nested transactions are not supported; attempting one returns an adapter error instead of creating a savepoint.
- Existing experimental JSONB-backed array columns should be migrated manually; the planner reports those as type mismatches.
Status
Beta/release-candidate quality for the RustAuth Postgres adapter contract, but public APIs may still evolve before stable 1.0.
Better Auth compatibility
Server-side pooled Postgres DbAdapter and rate-limit storage. Aligned with Better
Auth 1.6.9 where it matters for this crate; RustAuth is not a line-by-line port.
For route-level parity, test counts, intentional differences, and known gaps, see UPSTREAM.md.