Skip to main content
ChameleonDB migrations are tightly integrated with the Schema Vault, providing automatic versioning, integrity verification, and a complete audit trail for every schema change.

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:
Output:

Preview Changes

Check what changes will be applied without executing them:
This command:
  • Compares your schema.cham with 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:
Output:

Apply Migration

Apply the migration to your database:
The first time you run chameleon migrate --apply, it automatically initializes the Schema Vault and registers your schema as v001.

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

Migrations are blocked in readonly mode. Upgrade if needed:
See Mode Management for details.
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:
Output:

Audit Trail

View the complete integrity log:

Migration Recovery

If a migration fails midway, ChameleonDB can retry automatically:
Output:

Environment Variables

Set your database connection string:
Alternatively, use a .env file:
.env

Integrity Verification

Automatic Verification

Every chameleon migrate command automatically:
  1. Verifies all schema hashes
  2. Detects tampering
  3. Aborts if integrity violation detected
Example (tampered vault):

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:
If changes were unauthorized, restore from backup.

”vault not initialized”

Solution: Run init first:

Best Practices

Preview SQL before applying to catch unexpected changes:
Lock schema changes in production environments:
Audit schema changes periodically:
Create snapshots before risky operations:
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