Installation
1. Install the CLI
cargo install zyvor-cli
zyvor --version # Zyvor-CLI 0.1.0
This gives you the zyvor command. It’s a build-time tool — your application
doesn’t depend on it.
2. Add the runtime
cargo add zyvor
cargo add sqlx --features runtime-tokio,postgres,chrono,rust_decimal,json
cargo add tokio --features full
cargo add serde --features derive
Building an API? Add Axum too:
cargo add axum serde_json
⚠️ The one rule that will save you an hour
Your sqlx version must match Zyvor’s. Zyvor 0.1 uses sqlx 0.8.
[dependencies]
zyvor = "0.1"
sqlx = { version = "0.8", features = ["runtime-tokio", "postgres"] }
cargo add sqlx grabs the newest release, which may be 0.9 or later. If you end
up on a different major-minor than Zyvor, you’ll see errors like:
the trait bound `UserModel: FromRow<'r, PgRow>` is not satisfied
the trait bound `&Pool<Postgres>: Acquire<'_>` is not satisfied
there are multiple different versions of crate `sqlx_core` in the dependency graph
That is not a Zyvor bug. Two sqlx versions means two distinct FromRow
traits, and your generated model implements the other one. Pin to 0.8 and the
errors disappear.
Check what you actually resolved:
cargo tree -i sqlx
One version in the tree = you’re fine.
3. PostgreSQL
You need a running PostgreSQL server and credentials for it.
You do not need to create the database. zyvor migrate --apply creates it
if it’s missing. Just pick a name and put it in your connection string.
4. What you don’t need
Zyvor re-exports what its generated code uses, so these are optional:
| Crate | Needed? |
|---|---|
chrono | ❌ not to hold a DateTime. ✅ if you want chrono APIs in your own code |
rust_decimal | ❌ not to hold a Decimal |
serde_json | ❌ not to hold a Json. ✅ if you build JSON responses by hand |
serde | ✅ for your own DTO derives (or use zyvor::serde::Serialize) |
For timestamps in your own code, the sqlx re-export is free:
#![allow(unused)]
fn main() {
use sqlx::types::chrono;
let now = chrono::Utc::now().timestamp();
}
Verify
zyvor --version # CLI installed
cargo check # runtime + sqlx versions agree
Next: Quick Start.