Installing PostgreMQ
Installation creates the postgremq schema, its functions and tables, and migration tracking. It does not start a queue service or schedule maintenance. Application data may already exist in other schemas of the same database.
Use an installer role that can create the schema and its objects. Keep its credentials separate from runtime roles. PostgreSQL 15 or later is required; connect to the writable database where queue state should live.
Install with the CLI
Choose a released Go component whose embedded migrations reach the intended SQL release. The CLI's package version is independent of the SQL version it installs. Obtain the mapping from Releases and inspect the chosen tool's status output.
Set CLI_VERSION to the selected Go release including its v prefix and set DATABASE_URL through your normal credential management. For example, use v0.4.0, not the repository tag postgremq-go/v0.4.0; select the actual target from the release mapping. The example installs into a private tool directory:
: "${CLI_VERSION:?Set CLI_VERSION to the selected Go release}"
: "${DATABASE_URL:?Set DATABASE_URL for the target database}"
mkdir -p .tools
GOBIN="$PWD/.tools" go install "postgremq.dev/postgremq-go/cmd/postgremq@$CLI_VERSION"
.tools/postgremq status --dsn "$DATABASE_URL"
.tools/postgremq migrate --dsn "$DATABASE_URL"
.tools/postgremq status --dsn "$DATABASE_URL"
Before a fresh installation, status reports that migrations have not been applied. After migration, the current version should match the selected tool's latest embedded version and Dirty should be false. Status exit code zero means the query succeeded; inspect the fields to establish installation state.
If a PostgreMQ installation is already present, use Upgrading. Do not replace it by running the full schema script.
Verify and hand over to applications
Check discovery with the installer connection:
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -c 'SELECT postgremq.info();'
The result contains the encoded schema version and compatibility information. Compare it with the selected release; a response alone does not prove all application roles have the required access.
Apply runtime grants, then run the Quick start's application flow using the runtime login against an isolated test topic and queue in this installation. Verify publication, receipt, and acknowledgement. Do not run migrations using that restricted role merely to make the test pass.
Schedule Maintenance before handing the installation to production workers. Add Monitoring so a clean schema version cannot mask a stopped scheduler or growing backlog.
Alternative installation paths
The SDKs expose migration functions for applications that own deployment orchestration: Go Migrate, Rust migrate, and TypeScript migrate. They apply the migrations embedded in that SDK and share the CLI's migration tracking. Use one deliberate deployment step; the fact that concurrent migrators coordinate does not make startup migration in every replica necessary.
A released full SQL script is another option for a fresh installation. Set SQL_VERSION to the selected SQL version without v:
: "${SQL_VERSION:?Set SQL_VERSION to the selected SQL release}"
curl -fL "https://github.com/postgremq/postgremq/releases/download/mq/v${SQL_VERSION}/postgremq-v${SQL_VERSION}.sql" -o postgremq-install.sql
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f postgremq-install.sql
Review the downloaded release artifact through your normal software supply process. The script records migration state so later CLI upgrades work. It refuses an already tracked installation. --single-transaction makes a failed script roll back instead of leaving a partial installation. Preserve the first error if installation fails and follow Migration troubleshooting; repeated execution is not a repair strategy for arbitrary partial state.
Remove an installation
Removal deletes every PostgreMQ topic, queue, payload, delivery, dead letter, and function in this database. Stop publishers, consumers, and maintenance first. Take and verify any required backup, and inspect dependencies: CASCADE can also remove objects outside the schema that depend on PostgreMQ objects.
Only after deciding to discard that installation, run as its owner:
DROP SCHEMA postgremq CASCADE;
SELECT to_regnamespace('postgremq');
The final result should be null. This is full removal, not a downgrade or ordinary retention operation.