Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Database & Schemas

RustF’s CLI supports a database-first workflow and a schema-first workflow.

Database-First

Start from an existing database:

rustf-cli db generate-schema -o schemas
rustf-cli schema generate models -o src/models

db generate-schema writes YAML schema files and, by default, a full DDL dump:

schemas/_database_dump.sql

That SQL dump is the canonical source-controlled snapshot of the live database structure.

Schema-First

Start from YAML schema files:

rustf-cli schema validate
rustf-cli schema generate models
rustf-cli schema generate sql

Most Useful Commands

Inspect the Database

rustf-cli db test-connection
rustf-cli db list-tables --metadata
rustf-cli db describe users

Sync Schemas

rustf-cli db diff-schema schemas/users.yaml
rustf-cli schema check-consistency

Generate Code

rustf-cli schema generate models --force
rustf-cli schema generate sql --output sql

Backups and Safety

Commands with --force create backups under .rustf/backups/ before overwriting generated artifacts.