dpg apply

dpg apply

Execute the planned migration and update the snapshot

Synopsis

Runs dpg plan, prompts for approval, executes the SQL against the primary node, and updates the committed snapshot on success.

Destructive operations are blocked unless –allow-destructive is set. Partition strategy changes additionally require –approve-partition-rebuild.

With –dry-run, the migration is computed and printed but never executed. With –no-snapshot, the snapshot is not updated after a successful apply. With –strict, lint warnings are promoted to errors and block the apply.

Before anything runs (also with –dry-run), apply checks the database is as the migrations expect: no drift on the objects they change, nothing they create already there, nothing DPG doesn’t manage depending on what they drop or recreate. It refuses (exit 1) otherwise; –allow-drift proceeds anyway. Each migration also carries these checks as guards that any runner executes.

Each apply records its migration in the migration log beside the snapshot, and each database records the migrations it has run in its ledger table. apply first runs the log’s migrations a database hasn’t run (a database that is behind catches up), then the source’s change.

–baseline starts the log of a snapshot that predates it, and records in a database that has the log’s objects but no ledger how far along the log it is. –resume finishes a migration whose steps after its transaction failed.

dpg apply [flags]

Options

      --allow-destructive           allow destructive operations
      --allow-drift                 run even when the database isn't as the migration expects (and skip the migration's guards)
      --approve-partition-rebuild   acknowledge an instruction-only partition strategy rebuild step
      --baseline                    start the migration log of a snapshot that predates it, and record how far along it each database is
      --cluster string              cluster to apply (required when multiple clusters exist)
      --database string             database to apply (required when multiple databases exist)
      --dry-run                     print the migration plan but do not execute or update the snapshot
  -h, --help                        help for apply
      --no-snapshot                 skip snapshot update after a successful apply
      --resume                      finish a migration whose steps after its transaction failed
      --strict                      treat lint warnings as errors (blocks apply if any exist)
  -y, --yes                         skip interactive approval prompt

Options inherited from parent commands

  -C, --dir string   project root directory (default: current working directory)
      --env string   path to .env file (default: .env in project root, if present)

SEE ALSO

  • dpg - Declarative PG — schema compiler and migration tool
Auto generated by spf13/cobra on 12-Oct-2026