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.
devproduces the migration files. Runningmigrate --applybeforedevgives youNo 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:
- The database is created if missing. You never run
CREATE DATABASEby hand. Zyvor connects to thepostgresmaintenance database, checkspg_database, and creates your target if needed. - Checksums make re-runs free. Each file’s SQL is hashed and recorded in
_zyvor_migrations. Same name + same checksum → skipped. - 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
| Command | What 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:
--database <URL>flagDATABASE_URLenvironment variable.zyvor/.env.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.