Skip to content

Offline & Change Detection

Two operational features: generating without a live database, and seeing what changed in the schema since your last generation.

Offline generation

When you have no database connection available (air-gapped, CI, security-sensitive environments), generate in two phases.

1. Online, once — export routine metadata

db-gen routines --config db-gen.json

This writes the RoutinesFile (default ./db-gen-routines.json) containing the metadata of all selected routines.

2. Offline, any time — generate from the file

Set UseRoutinesFile and generate:

{
  "UseRoutinesFile": true,
  "RoutinesFile": "./db-gen-routines.json"
}
db-gen generate --config db-gen.json

db-gen reads routine metadata from the JSON file instead of connecting.

Copy targets need a connection

Copy targets read column metadata directly from information_schema and are not part of the routines file. They require a live database connection.

Change detection

db-gen records the routine and copy-target metadata it generated against (in a generation-information file in the output folder). On the next run it diffs the live schema against that record.

Command Behavior
generate Prints the changes, then regenerates.
database-changes Prints the changes only — no files written.

What is reported

For routines:

  • created / deleted functions
  • renamed parameters
  • parameter type changes
  • parameter nullability changes
  • added / removed parameters

For copy-target tables:

  • created / deleted tables
  • added / removed columns
  • column type changes
  • column nullability changes

Detect drift in CI

Run database-changes in CI to detect schema drift without touching generated files:

db-gen database-changes --config db-gen.json

This is what closes the gap where a changed staging-table column used to be silent — copy-target tables are now tracked alongside routines. See Copy Targets.