Exit codes and reports
Every command ends with an exit code your pipeline can act on, and can write reports you keep as build artifacts.
On this page
Exit codes
| Code | Meaning |
|---|---|
| 0 | No differences (compare), or the dry run or apply succeeded. |
| 1 | Differences found (unless --no-fail-on-drift), or the dry run or apply failed. |
| 2 | A configuration, file, connection or seat-lease problem, or the licensing service could not be reached. |
| 3 | Refused by licensing: no valid license or trial for this action, or the file is revoked, expired or from another account. |
| 4 | The seat is busy with another run. Add --wait <duration> to queue instead. |
| 130 | Cancelled (Ctrl+C or the CI job was stopped). Uncommitted changes are rolled back, temporary databases are removed and the seat is released. |
Exit codes by command
| Command | 0 | 1 | 2 | 3 | 4 | 130 |
|---|---|---|---|---|---|---|
compare | No differences | Differences, or an incomplete read | Yes | Yes | Yes | Yes |
dry-run | Every step passed | A step failed | Yes | Yes | Yes | Yes |
apply | Applied | A step failed | Yes | Yes | Yes | Yes |
file inspect | Valid file | — | Unreadable or edited file | — | — | — |
Handling exit codes in Bash
dbhydrate compare --run release.dbhrun --report report.md
case $? in
0) echo "No schema drift" ;;
1) echo "Drift found: review report.md"; exit 1 ;;
3) echo "Refused by licensing: check the file and license"; exit 1 ;;
4) echo "Seat busy: retry later"; exit 1 ;;
*) echo "Run failed"; exit 1 ;;
esacHandling exit codes in PowerShell
dbhydrate compare --run release.dbhrun --report report.md
switch ($LASTEXITCODE) {
0 { "No schema drift" }
1 { "Drift found: review report.md"; exit 1 }
4 { "Seat busy: retry later"; exit 1 }
default { "Run failed"; exit 1 }
}Reports
CI runners are often wiped after each job, so every command can write its result to files you keep as build artifacts. Markdown (--report) is for people and pull-request comments; JSON (--json) is for other tools. A short summary always goes to the console.
| Report | Contains | SQL |
|---|---|---|
compare | Each differing object: type, name, change and whether it is destructive; totals; whether the read was complete | Never |
dry-run | Each step: passed or failed, the database’s error, timing | Licenses only |
apply | As dry run, plus applied, rolled back or failed | Licenses only |
Reports never contain passwords, passphrases, key shares or license keys.
JSON report example
{
"command": "compare",
"engine": "postgres",
"complete": true,
"differences": [
{ "object": "table", "name": "public.orders", "change": "changed",
"detail": "column \"discount_code\" missing on target", "destructive": false },
{ "object": "index", "name": "public.idx_orders_date", "change": "added", "destructive": false }
],
"totals": { "differences": 2, "destructive": 0 }
}An illustration of the planned structure. The final JSON format is published with the first release, and later changes will be versioned.