PostgreSQL Configuration
monetr’s primary database is PostgreSQL and is required in order for monetr to run. monetr also uses PostgreSQL as a
basic pub-sub system via LISTEN
and NOTIFY
commands.
Officially monetr supports PostgreSQL version 16 and higher.
postgresql:
address: "localhost"
port: 5432
username: "monetr"
password: "..."
database: "monetr"
insecureSkipVerify: false
caCertificatePath: "</tls/ca.cert>"
keyPath: "</tls/tls.key>"
certificatePath: "</tls/tls.cert>"
Name | Type | Default | Description |
---|---|---|---|
address | String | localhost | The IP, or DNS resolvable address of your PostgreSQL database server. |
port | Number | 5432 | Port that the PostgreSQL server can be reached at. |
username | String | postgres | Username that monetr should use to authenticate the PostgreSQL server. |
password | String | Password that monetr should use to authenticate the PostgreSQL server. | |
database | String | postgres | Database that monetr should use, monetr may attempt to run migrations on startup. The user monetr is using should have permissions to create tables and extensions. |
insecureSkipVerify | Boolean | false | If you are using TLS with PostgreSQL but are not distributing a certificate authority file, then you may need to skip TLS verification. |
caCertificatePath | String | Path to the certificate authority certificate file. If you are verifying your TLS connection then this is required or the server certificate must be among the hosts certificate authorities already. | |
keyPath | String | Path to the client TLS key that monetr should use to connect to the PostgreSQL server. | |
certificatePath | String | Path to the client TLS certificate that monetr should use to connect to the PostgreSQL server. |
monetr does watch for certificate changes on the filesystem to facilitate certificate rotation without needing to restart the server. However this functionality does not always work and should not be relied on at this time.
The following environment variables map to the following configuration file fields. Each field is documented below.
Variable | Config File Field |
---|---|
MONETR_PG_ADDRESS | postgresql.address |
MONETR_PG_PORT | postgresql.port |
MONETR_PG_USERNAME | postgresql.username |
MONETR_PG_PASSWORD | postgresql.password |
MONETR_PG_DATABASE | postgresql.database |
MONETR_PG_INSECURE_SKIP_VERIFY | postgresql.insecureSkipVerify |
MONETR_PG_CA_PATH | postgresql.caCertificatePath |
MONETR_PG_KEY_PATH | postgresql.keyPath |
MONETR_PG_CERT_PATH | postgresql.certificatePath |
Database Migrations
The provided Docker Compose file will automatically run database migrations on startup as needed. However if you want to
run the migrations manually you can remove the --migrate
flag from the serve command in the compose file.
To run database migrations manually run the following command:
monetr database migrate
To see the current database schema version run the following command:
monetr database version