zyvor migrate
Two modes: generate a SQL file, or apply migrations to a database.
Generate only
zyvor migrate # .zyvor/schema.zyvor → migrations/0001_initial.sql
zyvor migrate path/to/schema.zyvor # custom schema
zyvor migrate schema.zyvor out/custom.sql # custom output
Output directories are created as needed. Existing output files are overwritten.
Apply
zyvor migrate --apply
zyvor migrate --apply --database postgres://user:pass@localhost/mydb
This is the mode you’ll use daily. It:
- resolves the database URL
- creates the database if it doesn’t exist
- ensures
_zyvor_migrationsexists - scans
migrations/*.sql, sorts by filename - for each file: checksum → skip / drift-error / apply + record
- lists the resulting tables
🚀 Applying migrations to database...
Database: postgres://postgres:****@localhost/my_app
📦 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!
Tables in database:
📋 _zyvor_migrations
📋 posts
📋 users
Passwords are always masked in output.
Where the URL comes from
Highest priority first:
--database <URL>DATABASE_URLenvironment variable.zyvor/.env.zyvor/config.toml→[database] url
If none is found, you get an actionable error telling you exactly what to create.
Two errors you’ll actually see
No migration files
No migration files found in .zyvor/migrations/. Run 'zyvor dev' first.
dev generates the files. Run it before applying.
Schema drift
❌ Schema drift in '0001_initial.sql'! Checksum mismatch.
Old: 4a2f...
New: 9c1b...
You edited a migration that was already applied. Don’t do that — migrations are history. Write a new forward migration instead. If you’re intentionally resetting a dev database, drop it and re-apply from scratch.
Not available yet
migrate status, migrate reset, migrate dev, and rollback. To undo
something today, write a new migration that reverses it.