Skip to main content

CLI reference

This page describes CLI 0.4.0, released with the Go component, from source commit cbff27b8a34e1384384018680e46c20d5c610cc9. It embeds migrations through SQL 0.1.1. The CLI manages schema installation and upgrades; it has no queue-management, maintenance, monitoring, or backup subcommands.

Installation and connection​

Go 1.25 or later is required to install this release:

go install postgremq.dev/postgremq-go/cmd/postgremq@v0.4.0
postgremq --help

status and migrate require --dsn and accept pgx connection strings in URL or keyword/value form. -dsn is also accepted. The CLI does not read DATABASE_URL automatically; passing --dsn "$DATABASE_URL" is shell expansion. Missing individual connection settings can fall back to PostgreSQL driver environment settings.

Use the deployment's TLS and credential configuration. Avoid embedding secrets in checked-in commands or logs. The CLI has no version subcommand; record the selected package version when installing the binary.

Commands​

postgremq status --dsn "$DATABASE_URL"
postgremq migrate --dsn "$DATABASE_URL"
CommandBehavior
statusRead current tracking state and the tool's latest embedded version. Does not create a schema or tracking table.
migrateCreate the schema if needed and apply pending upward migrations through the latest embedded version. Reject dirty state.

postgremq <command> -h shows command help. The only operation flag is the required string --dsn. There is no target-version or downgrade flag.

If the database is newer than the tool's embedded migrations, migrate leaves it unchanged. Its “up to date” wording means that this binary has nothing pending, not that it is the newest available binary or an appropriate rollback tool.

Output and exit codes​

Status reports current version, latest embedded version, and Dirty. Versions use human-readable SQL release labels with encoded schema numbers. Before installation, current version is reported as none/schema version zero.

Exit codeMeaning
0Command succeeded. For status, includes dirty or pending state if it could be read.
1Connection, status-reading, migration, or dirty-state error. This includes a malformed DSN that the driver cannot parse.
2Usage error: no command, unknown command/flag, missing DSN, or unexpected arguments.

Errors are written to stderr. Status's final up-to-date or migration-needed line depends on versions; a dirty database can still print an up-to-date line. Always inspect Dirty. Use migrate's failure status to detect a refused migration, but do not run it merely as a read-only readiness probe.

Privileges and coordination​

Creating a missing postgremq schema requires database CREATE privilege. If the schema already exists, the migrator skips that step; the installer still needs permission to create and manage the required objects within it. Upgrade normally uses the installation owner. Reading an existing tracked status needs schema USAGE and SELECT on the migration table; before installation, connecting may be sufficient.

SDK migrators and the CLI share a tracking table and advisory-lock protocol. Coordination does not validate a risky rollout or eliminate migration lock impact on applications. Run migrations as a controlled deployment operation.

The tracking table records version and dirty state. A failed migration requires examination of actual schema changes; the CLI does not provide an automatic repair command. Follow Installation, Upgrading, or Migration troubleshooting for procedures.