Skip to main content

gen-pack

Generates a complete SQL migration pack that includes both schema changes (DDL) and data changes (DML). This is the main output artifact of DeepDiff DB — a single, reviewable SQL file ready to apply to production.

Usage

deepdiffdb gen-pack --config deepdiffdb.config.yaml

What It Generates

The migration pack is a single transactional SQL file containing:

  • Schema DDLALTER TABLE, CREATE TABLE, CREATE INDEX, ADD CONSTRAINT statements for schema differences
  • Data DMLDELETE + INSERT pairs (or UPDATE) for each changed row, batched in groups of 1000
  • Foreign key management — Driver-specific statements to disable FK checks before data changes and re-enable them after (e.g., SET FOREIGN_KEY_CHECKS=0 for MySQL, DISABLE CONSTRAINT ALL for Oracle)
  • Everything wrapped in a single BEGIN / COMMIT transaction

gen-pack internally runs the same diff logic as diff, so you always get a fresh pack based on the current state of both databases.

Flags

FlagDescription
--configPath to the configuration file (default: deepdiffdb.config.yaml)
--htmlGenerate an interactive HTML report (report.html)
--batch-size NRows per keyset-paginated query (overrides performance.hash_batch_size)
--parallel NMax tables hashed concurrently (overrides performance.max_parallel_tables)
--resumeResume from the last saved checkpoint
--verboseEnable debug-level logging
--log-levelMinimum log level: debug, info, warn, error (default: info)
--log-formatLog output format: text or json (default: text)
--log-fileWrite logs to this file in addition to stdout

Output Files

FileDescription
schema_diff.jsonSchema differences (informational; schema drift emits warnings but does not block)
content_diff.jsonRow-level differences
conflicts.jsonConflict details
summary.txtSummary statistics
resolutions_summary.jsonResolution statistics (when conflict resolutions exist)
migration_pack.sqlThe complete, transactional migration script
report.htmlInteractive HTML report (only when --html is used)

Example

# Standard pack generation
deepdiffdb gen-pack --config deepdiffdb.config.yaml

# With HTML report and parallelism for large databases
deepdiffdb gen-pack --config deepdiffdb.config.yaml --html --batch-size 5000 --parallel 4

# Resume a previously interrupted gen-pack
deepdiffdb gen-pack --config deepdiffdb.config.yaml --resume

Schema Drift Behaviour

Unlike diff, gen-pack does not abort on schema drift. It emits warnings for tables with schema differences and skips data diffing on those tables. Tables with matching schemas are processed normally. This lets you generate a pack that handles both the schema migration and data migration in a single file.

Resuming Interrupted Runs

If a gen-pack run is interrupted (network failure, process kill), restart with --resume:

deepdiffdb gen-pack --config deepdiffdb.config.yaml --resume

DeepDiff DB loads the last checkpoint and continues from where it left off. Checkpoints expire after 24 hours. See Checkpoint and Resume for details.