> For the complete documentation index, see [llms.txt](https://mercure-technologies.gitbook.io/xprem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mercure-technologies.gitbook.io/xprem/installation-guide/database-configuration.md).

# Database configuration

The xprem control plane uses PostgreSQL as its primary data store: updates, branches, channels, and rollouts all live there.

Before you begin, you need a running PostgreSQL instance that your xprem deployment will be able to reach.

### Creating the database

The server runs its schema migrations itself, but never creates the database.\
If your provider didn't already create a database for you, you can create one manually:

```shellscript
psql "postgresql://{{USER}}:{{PASSWORD}}@{{HOST}}:{{PORT}}/postgres" \
  -c 'CREATE DATABASE xprem;'
```

{% hint style="info" %}
This guide uses `xprem` as the database name, but any name works
{% endhint %}

Note down the connection string for the database you just created: you'll set it as `DB_URL` in your environment:

```shellscript
DB_URL=postgresql://{{USER}}:{{PASSWORD}}@{{HOST}}:{{PORT}}/xprem
```

### Generate the master key

xprem signs every update it serves. Your app embeds the matching certificate at build time and verifies that signature before applying an update so a compromised bucket or CDN can't push malicious code to your users.

The private signing keys live in your PostgreSQL database, encrypted at rest with your master key.

{% hint style="warning" %}
**Do not lose your master key. I**t is the only thing that can decrypt your signing keys, and there is no recovery path. Recovering means generating new signing keys, rebuilding your app, and shipping it through the app stores.
{% endhint %}

To generate the master key please run:

```shellscript
openssl rand -base64 32
```

You'll set this value as `DB_KEYS_MASTER_KEY_B64` in your environment

{% hint style="info" %}
If you are using AWS Secrets Manager, create a new key on AWS with this value and store the key id as `AWSSM_DB_KEYS_MASTER_KEY_SECRET_ID`
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mercure-technologies.gitbook.io/xprem/installation-guide/database-configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
