---
title: "Document Engine database privileges | Nutrient"
canonical_url: "https://www.nutrient.io/guides/document-engine/configuration/database-privileges/"
md_url: "https://www.nutrient.io/guides/document-engine/configuration/database-privileges.md"
last_updated: "2026-11-30T00:00:00.000Z"
description: "Set up the PostgreSQL schema and the privileges for the accounts Document Engine uses to run migrations and to serve requests."
---

# Database privileges

Document Engine connects to PostgreSQL with two kinds of accounts: one that runs database migrations, and one that its nodes use at runtime. They can be the same account. This guide describes the schema Document Engine uses and the privileges each account needs. For the connection and migration options, refer to the [database options](https://www.nutrient.io/guides/document-engine/configuration/options.md#database-options).

## Database and schema

Use a PostgreSQL database dedicated to Document Engine. Document Engine stores its database objects in the `public` schema. A different schema can’t be configured.

Put `public` first on the `search_path` of the migration account, because Document Engine creates its tables in that schema. The account that Document Engine nodes connect as needs `public` on its `search_path` too.

## Migration account

The account that runs migrations (`PG_ADMIN_USER`, or `PGUSER` when it’s not set) needs to:

- Use and create objects in the `public` schema.

- Create temporary tables in the database.

- Own the existing Document Engine objects, or inherit the privileges of their owner, when it migrates an existing database.

- Create the PostgreSQL extensions that migrations install, unless they’re already installed (`pg_buffercache`, `pg_freespacemap`, `pgrowlocks`, `pg_stat_statements`, `pgstattuple`, `pg_visibility`, `btree_gist`, `btree_gin`, `intarray`, and `uuid-ossp`). Migrations skip `pg_freespacemap` and `pg_visibility` when the server doesn’t offer them. On self-managed PostgreSQL, the first six require a superuser, and the others require `CREATE` on the database. Managed database services have their own extension permissions. If the migration account can’t install them, a database administrator must install them in the Document Engine database before migration.

- Create the database, if it doesn’t exist yet. This requires the `CREATEDB` attribute and the `en_US.UTF-8` locale on the server. Otherwise, create the database yourself with UTF-8 encoding.

To check the schema and temporary table privileges, run this read-only query in the Document Engine database. Replace `migrator` with the migration account:

```sql
SELECT has_schema_privilege('migrator', 'public', 'USAGE')
         AND has_schema_privilege('migrator', 'public', 'CREATE') AS can_create_in_public,
       has_database_privilege('migrator', current_database(), 'TEMP') AS can_create_temp_tables;
```

Both columns return `true` when the privileges are in place.

## Runtime account

The intended runtime account is `PGUSER`. This is usually the same account as `PG_OPERATION_USER`, which defaults to `PGUSER`. If `PG_ADMIN_USER` and `PG_ADMIN_PASSWORD` are set on nodes that don’t run migrations, they override `PGUSER` and `PGPASSWORD`. The node then connects with the migration account’s credentials. The runtime account needs:

- `CONNECT` on the database and `USAGE` on `public`.

- `SELECT`, `INSERT`, `UPDATE`, and `DELETE` on Document Engine’s tables in `public`.

- `SELECT`, `USAGE`, and `UPDATE` on Document Engine’s sequences in `public`.

- `EXECUTE` on the functions Document Engine uses, such as `uuid_generate_v4()`, if you revoked it from `PUBLIC`.

When you use a dedicated migration job (`ENABLE_DATABASE_MIGRATIONS` and `EXIT_AFTER_DATABASE_MIGRATIONS` set to `true`), schema migrations can complete before runtime privilege configuration fails. Before starting runtime nodes, make sure the runtime account has all the privileges listed above.
---

## Related pages

- [Asset storage configuration](/guides/document-engine/configuration/asset-storage.md)
- [Cache configuration](/guides/document-engine/configuration/cache.md)
- [Certificate trust settings](/guides/document-engine/configuration/certificate-trust.md)
- [How to configure custom fonts in Document Engine](/guides/document-engine/configuration/custom-fonts.md)
- [Speed up search with a full-text index](/guides/document-engine/configuration/full-text-search.md)
- [HTTP/2 shared rendering](/guides/document-engine/configuration/http2-shared-rendering.md)
- [Document Engine container](/guides/document-engine/configuration/large-documents.md)
- [Configuration options](/guides/document-engine/configuration/options.md)
- [Preferred annotation fonts in Document Engine](/guides/document-engine/configuration/preferred-annotation-fonts.md)

