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
| Option | Description |
|---|---|
--remote <name> | Use specific remote (otherwise uses default) |
--url <url> | Direct URL override |
-f | Skip confirmation prompts |
--dry-run | Verify only, don't touch target |
-v, --verbose | Enable verbose output |
--json | Output 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
- Resolves the target database URL (from remote config or
--urlflag) - If an active session exists, removes it (with confirmation unless
-f) - Tests the target database connection and detects its PostgreSQL major version
- If
localDbUrlis empty: Starts a temporarypostgres:{version}-alpinecontainer for the dry-run, version-matched to the target - Clones the target database to local for dry-run verification. When using a temp container, cloning runs via
docker execinside the container - Runs a full dry-run on the local clone: infra, dbmate migrate, seeds
- If
--dry-runis set, stops here and reports results without touching the target - Reports dry-run results and confirms deployment (unless
-f) - Applies to target: infra, dbmate migrate, seeds
- Drops the local clone database; stops and removes the temp container if one was used
If the dry run fails, deployment is aborted and no changes are made to the target database.
Requirements
- Committed migrations must exist (run
db commitfirst) localDbUrlmust be different from the target remote URL (or leave it empty to use an auto-container)- Docker must be running if
localDbUrlis empty