Skip to content

Migrations & Incremental Seeding

When your schema evolves, DBSprout can report exactly what changed and apply only the necessary updates to existing seed data.

dbsprout diff compares the current schema against the stored snapshot and prints a human-readable change report:

Terminal window
# Compare a live database against the latest snapshot
dbsprout diff --db postgresql://localhost/myapp
# Compare a schema file instead
dbsprout diff --file schema_v2.sql
# Diff against a specific snapshot, as JSON (for CI)
dbsprout diff --snapshot a1b2c3d4 --format json

Detected changes include added/removed tables, added/removed/retyped columns, nullability and default changes, and added/removed foreign keys and indexes.

Instead of regenerating every table, apply only the diff-driven changes to the existing seed data:

Terminal window
# Update against the latest snapshot
dbsprout generate --incremental
# Update against a new schema file or a specific snapshot
dbsprout generate --incremental --file schema_v2.sql
dbsprout generate --incremental --snapshot a1b2c3d4

Each change type maps to a targeted update rule (new column → backfill, new table → generate, dropped table → skip, …) so unaffected data is preserved.

DBSprout understands common migration formats, so a schema can be derived from a migration history rather than a live database:

FrameworkFormat
AlembicPython migration scripts
Djangomigrations/ operations
FlywayVersioned SQL migrations
LiquibaseXML changelogs
Prismamigration.sql files

Point --file at a migration source the same way you would a DDL file.