PostgreSQL Deployment
With databaseType = postgresql the Enterprise Stack stores its documents as JSONB in PostgreSQL, one table per collection.
The API connects over JDBC. It does not use the MongoDB wire protocol, and there is no migration from an existing MongoDB
database.
Loading diagram...
This is not DocumentDB. To run on DocumentDB on PostgreSQL or on Azure DocumentDB through the MongoDB wire protocol, see DocumentDB Deployment.
Prerequisites
Before you begin, ensure you have:
- An Enterprise Stack license, see Licensing. The API refuses to start without an active license.
- PostgreSQL 13 or later. The API refuses to start on an older server. Versions 15 to 18 are currently tested; 13 and 14 start with a warning.
- An empty database and a login that can create tables in it. The API creates and migrates its schema on startup. It needs no extensions and no superuser.
From PostgreSQL 15, the public schema no longer lets every login create tables. If the login does not own the schema the
API uses, grant it CREATE on that schema, or point the API at a schema it owns with currentSchema on the JDBC URL or the
schema field.
Option 1: Quickstart
For evaluation and development. The Enterprise Stack Quickstart
ships docker-compose-postgresql.yml, which runs the API next to a postgres:18 container:
docker compose -f docker-compose-postgresql.yml up
This stack has no reverse proxy. The API listens on port 7500, so run the quickstart CLI with PORT=7500. To run it next to
the MongoDB stack, set ENTERPRISE_API_PORT to another port.
Option 2: Your Own PostgreSQL
Point the API at the primary in database.conf:
databaseType = postgresql
postgresql = {
connectionString = "jdbc:postgresql://{host}:5432/waltid_enterprise?sslmode=verify-full&sslrootcert={caFile}"
username = "{username}"
password = "{password}"
}
TLS settings go on the JDBC connection string. ssl.enable = true only adds sslmode=require, which encrypts without
verifying the server certificate. Pool size, poolers, and the remaining fields are described in
Database configuration.
Managed PostgreSQL
Amazon RDS for PostgreSQL, as created by the quickstart's Terraform module with ssl.enable = true, is the setup the
load tests run on. RDS Proxy,
IAM database authentication, and Aurora PostgreSQL are not tested and not supported. The API signs in with the configured
username and password only.
Schema Upgrades
The schema is a list of numbered steps. On startup the API applies the steps a database does not have yet, in one transaction. Replicas that start together wait for each other, so each step runs once. Upgrading the API therefore upgrades the schema on its first start; there is no separate migration command.
The API refuses to start, and changes nothing, when:
- The database records a step newer than the build. Run the newer build, or restore a backup taken before it.
- The recorded steps do not match the build. The message names each version with its recorded and expected remark. A
hand-edited
enterprise_schema_migrationstable gets this message too. - The database was created by an early preview of the PostgreSQL backend.
For a disposable database in the last two cases, start once with recreateOnStart, see
Database configuration.
Limits and Differences from MongoDB
- Primary only. Point every API replica at the primary. A comma-separated host list is accepted, and the API connects only to the primary in it. A hot standby is refused. Reads are not split to replicas.
- Connections. A request can hold two connections. Keep
pool.maxSize(default 24) times the number of replicas, times two, undermax_connections. - Licensing.
usageCheckpointEnginemust staytrue, the default. The API refuses to start otherwise. - Queries. A filter that cannot be expressed in SQL, such as an arbitrary regular expression, is applied in memory. Such
a request fails with
400when it would scan more than 10,000 rows. - Trust registries. Trust sources, entities, services, and identities are stored in their own tables. Listing a trust
registry's children with
resource-api/resources/listreturns none of them on PostgreSQL, while MongoDB lists them. Read them through the Trust Registry API. - Event order.
POST /v1/events/querywithlimitreturns events with the same timestamp in id order on PostgreSQL. On MongoDB they come in insertion order. Do not rely on the order within one timestamp.
Usage counts, event retention, and organization export and import work on PostgreSQL as on MongoDB.
Start and Verify
A new database has no license state. Activate the license as described in Licensing. A license binds to one installation at a time.
The applied schema versions are recorded in the database:
SELECT version, remark FROM enterprise_schema_migrations ORDER BY version;
Next Steps
- Database configuration — all
postgresqlfields. - Licensing — activate the license for the new database.
- Docker deployment — run the Enterprise Stack image.
- DocumentDB Deployment — the MongoDB wire protocol on PostgreSQL.
