CLI Overview
pgtofu provides a command-line interface for managing PostgreSQL and TimescaleDB schemas declaratively. The CLI follows a simple workflow: extract, diff, generate, and apply.Commands
Global Flags
All commands support these global flags:Environment Variables
| Variable | Description | Used By |
|---|---|---|
DATABASE_URL | PostgreSQL connection URL | extract |
Workflow
The typical pgtofu workflow involves these steps:Output Formats
JSON Schema
Theextract command outputs a JSON file containing the complete database schema:
Migration Files
Thegenerate command creates golang-migrate compatible files:
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (invalid arguments, file errors, etc.) |
| 2 | Database connection error |
| 3 | Schema parsing error |