dibs
Call dibs on your database schema.
A Postgres toolkit for Rust, powered by facet reflection.
Vision
dibs is a batteries-included Postgres library that gives you:
- Schema definition via Rust structs with facet attributes
- Migrations as Rust functions, auto-discovered at runtime
- Schema diffing - detect drift between your code and your database
- Query building - type-safe queries without a full ORM
- Data mapping - seamless row-to-struct conversion
All built on facet's reflection system - no code generation, no build.rs, no macros that hide what's happening.
Example
use *;
use Facet;
// Queries
let user = db..await?;
let users = db.
.filter
.order_by
.all
.await?;
// Mutations
db.insert.await?;
db.update.await?;
db..await?;
Migrations
Migrations are Rust functions, not SQL files. This lets you do complex data migrations with real logic:
use *;
async
Run migrations:
$ dibs migrate
Applied 2026-01-17-normalize-emails (32ms)
Schema Diffing
Compare your Rust types against the live database:
$ dibs diff
Changes detected:
users:
+ email_normalized: TEXT (nullable)
~ name: VARCHAR(100) -> TEXT
tenants:
(no changes)
Run `dibs generate` to create a migration.
Generate a migration skeleton:
$ dibs generate add-email-normalized
Created: migrations/2026-01-17-add-email-normalized.rs
CLI
dibs migrate Run pending migrations
dibs rollback Rollback the last migration
dibs status Show migration status
dibs diff Compare schema to database
dibs generate Generate a migration skeleton
dibs schema Dump the current schema
Non-Goals
- Database agnosticism - This is for Postgres. Use sqlx if you need portability.
- Full ORM - No lazy loading, no relation mapping magic. Just queries.
- Hiding SQL - You should know what queries are running.
License
MIT OR Apache-2.0