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

CLI Commands

cargo install zyvor-cli

zyvor init

Scaffolds the project:

.zyvor/
├── schema.zyvor    ← template schema
├── .env            ← DATABASE_URL
├── config.toml
├── .gitignore      ← ignores .env
├── generated/
└── migrations/

Skips safely if .zyvor/ already exists.

zyvor dev

Generates once, then watches schema.zyvor and regenerates on save (300 ms debounce for editor double-writes).

✅ Generated 13 modular files in ".zyvor/generated"
✅ Generated: .zyvor/migrations/0001_initial.sql
💾 Snapshot saved
👀 Watching .zyvor/schema.zyvor for changes...

On a schema change it also diffs against snapshot.json and writes an auto-numbered incremental migration:

🔄 Schema change detected! Generated: 0002_schema_update.sql

Order matters. dev produces the migration files. Running migrate --apply before dev gives you No migration files found in .zyvor/migrations/.

zyvor migrate --apply

Applies every .sql file in order, tracking what’s already run.

📦 Creating database 'my_app'...
✅ Database 'my_app' created!
📋 Found 2 migration file(s)

⏭️  0001_initial.sql already applied. Skipping.
📝 Applying: 0002_schema_update.sql
✅ 0002_schema_update.sql applied successfully!

Three things happen here worth calling out:

  1. The database is created if missing. You never run CREATE DATABASE by hand. Zyvor connects to the postgres maintenance database, checks pg_database, and creates your target if needed.
  2. Checksums make re-runs free. Each file’s SQL is hashed and recorded in _zyvor_migrations. Same name + same checksum → skipped.
  3. Edited an applied migration? You get an error, not silent drift. Same name + different checksum → hard stop with both hashes shown.

Passwords are masked in all console output.

zyvor generate / zyvor validate

CommandWhat it does
zyvor validate [SCHEMA]lex → parse → validate, no output written
zyvor generate [SCHEMA]one-shot entity generation, no watching

Configuration

Resolution order, highest priority first:

  1. --database <URL> flag
  2. DATABASE_URL environment variable
  3. .zyvor/.env
  4. .zyvor/config.toml → [database] url = "..."

Not implemented yet

migrate status, migrate reset, migrate dev, and rollback. If you need to undo, write a new forward migration — that’s the honest workflow today.