Overview
Unlike traditional migration tools, ChameleonDB:- Automatically registers schema versions on every migration
- Verifies integrity before applying changes
- Enforces mode restrictions (readonly blocks migrations)
- Maintains an append-only audit trail
- Enables migration recovery for failed attempts
Migration Commands
Check Migration Status
View the current state of your database and schema:Preview Changes
Check what changes will be applied without executing them:- Compares your
schema.chamwith the current database state - Shows a diff of detected changes
- Does NOT apply migrations
Dry Run (View Generated SQL)
See the exact SQL that will be executed:Apply Migration
Apply the migration to your database:Complete Migration Workflow
1
Modify Your Schema
Edit your
schema.cham file to add, remove, or modify entities and fields:2
Validate Schema Syntax
Ensure your schema is syntactically correct:Output:
3
Preview Migration
Check what changes will be applied:Review the generated SQL to ensure it matches your intentions.
4
Ensure Proper Mode
5
Apply Migration
Execute the migration:Output:
6
Verify Integrity
Confirm the migration was recorded correctly:Output:
Schema Vault Integration
Every migration creates an immutable version in the vault:Vault Structure
Version History
View all schema versions:Audit Trail
View the complete integrity log:Migration Recovery
If a migration fails midway, ChameleonDB can retry automatically:Environment Variables
Set your database connection string:.env file:
.env
Integrity Verification
Automatic Verification
Everychameleon migrate command automatically:
- Verifies all schema hashes
- Detects tampering
- Aborts if integrity violation detected
Manual Verification
Verify vault integrity anytime:Common Issues
”readonly mode: schema modifications blocked”
Solution: Upgrade mode to standard or higher:“DATABASE_URL not set”
Solution: Set environment variable:“integrity violation detected”
Solution: Someone modified vault files. Check audit log:”vault not initialized”
Solution: Run init first:Best Practices
Always run dry-run first
Always run dry-run first
Preview SQL before applying to catch unexpected changes:
Use readonly mode in production
Use readonly mode in production
Lock schema changes in production environments:
Review version history regularly
Review version history regularly
Audit schema changes periodically:
Backup vault before major changes
Backup vault before major changes
Create snapshots before risky operations:
Set DATABASE_URL in .env
Set DATABASE_URL in .env
Keep connection strings out of version control:
Next Steps
Introspection
Generate schema from existing databases
Mode Management
Control schema change permissions
Debugging
Troubleshoot migrations and queries
Architecture
Understand the Schema Vault system