Skip to main content

db deploy

Deploy committed migrations to a remote database with dry-run verification.

Usage

postkit db deploy [--remote <name>] [--url <url>] [-f] [--dry-run]

Options

OptionDescription
--remote <name>Use specific remote (otherwise uses default)
--url <url>Direct URL override
-fSkip confirmation prompts
--dry-runVerify only, don't touch target
-v, --verboseEnable verbose output
--jsonOutput as JSON

Examples

# Uses default remote
postkit db deploy

# Use specific remote
postkit db deploy --remote staging

# Dry run to verify
postkit db deploy --remote production --dry-run

# Skip confirmations
postkit db deploy --remote staging -f

What It Does

  1. Resolves the target database URL (from remote config or --url flag)
  2. If an active session exists, removes it (with confirmation unless -f)
  3. Tests the target database connection
  4. Clones the target database to local (using LOCAL_DATABASE_URL)
  5. Runs a full dry-run on the local clone: infra, dbmate migrate, grants, seeds
  6. If --dry-run is set, stops here and reports results
  7. Reports dry-run results and confirms deployment (unless -f)
  8. Applies to target: infra, dbmate migrate, grants, seeds
  9. Drops the local clone database
  10. Marks migrations as deployed in .postkit/db/committed.json

If the dry run fails, deployment is aborted and no changes are made to the target database.

Requirements

  • Committed migrations must exist (run db commit first)
  • PostgreSQL client tools must be installed