Export Schema
Use the Pro export-schema command to capture database schema as SQL migration files. It reads from a live database, a stored snapshot in the database, or a JSON snapshot file on disk.
This is different from Enterprise snapshot, which exports a portable JSON model for plan, preflight, and diff workflows. Use export-schema when you need SQL scripts — for example a brownfield baseline or a split-by-type migration layout.
Common workflows
Baseline from an existing database:
dblift export-schema --output migrations/V1__baseline.sql
Export only objects not yet managed by DBLift migrations (brownfield):
dblift export-schema --unmanaged-only --output migrations/unmanaged.sql
Export only objects defined in applied migrations:
dblift export-schema --managed-only --output migrations/managed.sql
Split output by object type:
dblift export-schema --split-by-type --output-dir migrations/baseline/
Export from a committed snapshot model (no live DB):
dblift export-schema \--source file-model \--snapshot-model snapshots/schema.json \--output migrations/V1__baseline.sql
Export from the latest snapshot stored in the database:
dblift export-schema --source database-model --output migrations/V1__baseline.sql
Source options
--source | Description |
|---|---|
live-database (default) | Introspect the configured database connection |
database-model | Read the latest schema snapshot stored in the database |
file-model | Read a JSON snapshot file (--snapshot-model required) |
Filtering options
| Option | Description |
|---|---|
--schema | Export a single schema (defaults to configured schema) |
--tables | Comma-separated table names (includes related objects) |
--types | Object types to include, e.g. tables,views,functions,triggers |
--managed-only | Only objects tracked by applied migrations |
--unmanaged-only | Only objects not tracked by migrations |
--tags / --exclude-tags | Filter which migrations define managed objects |
--versions / --exclude-versions | Filter by migration version |
--target-version | Consider migrations up to this version only |
--include-drops | Emit DROP statements for clean recreation |
--description | Text included in the migration header |
Output options
| Option | Description |
|---|---|
--output | Single output file |
--output-dir | Directory output (required with --split-by-type) |
--split-by-type | Write separate files per object type |
Typical brownfield adoption
- Export unmanaged objects as a baseline migration.
- Run
dblift baselineso DBLift treats the current state as already applied. - Add new versioned migrations for future changes.
See Commands for the full option list and Snapshots for portable JSON models used by Enterprise workflows.