Diesel CLI
$ diesel Official Med RiskDiesel CLI (diesel) manages database setup, versioned up.sql/down.sql migrations, and compile-time Rust table! macro codegen via diesel print-schema. Supports DATABASE_URL env configuration and non-interactive CI migration workflows.
brew install diesel diesel print-schema directly writes Rust table! macros into src/schema.rs for cargo check loops, which an MCP server cannot replace.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Commands like diesel migration list and diesel print-schema run headlessly with clear exit codes, though stdout is plain text without --json.
- Non-interactive
migration list,migration run, andprint-schemacommands - No native
--jsonoutput mode
Explicit up.sql/down.sql files are easy to audit before running, while diesel database reset drops and recreates the target database.
- Plain SQL migration files inspectable prior to execution
diesel database resetis destructive on target DB
Available via brew install diesel and cargo install diesel_cli, though Cargo builds require native libpq, sqlite, or mysqlclient headers unless --features is scoped.
- Homebrew binary formula and
cargo install diesel_cliacross macOS, Linux, and Windows
Tightly integrates database migrations with compile-time checked src/schema.rs codegen for Rust codebases.
- Automates
table!macro generation viadiesel print-schema
Official diesel-rs/diesel project with long-term Rust ecosystem stewardship under MIT/Apache-2.0.
- Official
diesel-rs/dieselrepository
Well-documented getting-started guides, diesel.toml reference, and structured --help output.
- Official guides at diesel.rs and subcommand
--help
Security, Auth & Guardrails
Reads DATABASE_URL from the process environment, .env, or --database-url flag; schema generation options live in diesel.toml.
Dual-licensed MIT/Apache-2.0 open-source CLI; free to use locally and in CI.
# Diesel CLI Agent Rules - Run `diesel migration list` before applying migrations and check both `up.sql` and `down.sql`. - Never run `diesel database reset` or `diesel migration redo` against shared or production `DATABASE_URL` targets.
Agent-Ready Command Recipes
Safe Read-Only Queries
diesel migration list
Shows each migration directory entry with [X] for applied and [ ] for pending status.
diesel print-schema --only-tables users,orders
Introspects the connected database and outputs table! macros without modifying local files unless redirected.
Controlled Writes & Previews
diesel migration run --locked-schema
Applies pending up.sql migrations non-interactively while failing if src/schema.rs would drift unexpectedly.
Strengths for Agents
- + Generates compile-time checked Rust
src/schema.rsdirectly from live DB state. - + Plain SQL
up.sqlanddown.sqlfiles keep every schema change human- and agent-reviewable. - + Reads
DATABASE_URLfrom env or.envfor frictionless local and CI runs.
Caveats & Pitfalls
- ! No
--jsonoutput flag ondiesel migration listor status checks. - !
cargo install diesel_clifails without C client libraries (libpq/mysqlclient) unless--no-default-featuresis passed.