PostgreSQL Configuration

Warning

monetr is migrating from using this configuration to a new config layout, this configuration will continue to work for the next few releases but will eventually stop working and require configuration files to be updated. If you are configuring your server via environment variables you should be fine.

See Database Configuration for more details.

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.

config.yaml
postgresql:
  address: "localhost"
  port: 5432
  username: "monetr"
  password: "..."
  database: "monetr"
  tls: false
  insecureSkipVerify: false
  caCertificatePath: "</tls/ca.cert>"
  keyPath: "</tls/tls.key>"
  certificatePath: "</tls/tls.cert>"
NameTypeDefaultDescription
addressStringlocalhostThe IP, or DNS resolvable address of your PostgreSQL database server.
portNumber5432Port that the PostgreSQL server can be reached at.
usernameStringpostgresUsername that monetr should use to authenticate the PostgreSQL server.
passwordStringPassword that monetr should use to authenticate the PostgreSQL server.
databaseStringpostgresDatabase 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.
tlsBooleanfalseIf true then monetr will connect to PostgreSQL using TLS. TLS is also used if any of the certificate paths below are provided.
insecureSkipVerifyBooleanfalseIf you are using TLS with PostgreSQL but are not distributing a certificate authority file, then you may need to skip TLS verification.
caCertificatePathStringPath 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.
keyPathStringPath to the client TLS key that monetr should use to connect to the PostgreSQL server.
certificatePathStringPath to the client TLS certificate that monetr should use to connect to the PostgreSQL server.
migrateBooleantrueAutomatically apply database migrations on startup.
Info

monetr watches the certificate files for changes, so certificates can be rotated without restarting the server. New connections to PostgreSQL will use the new certificates right away, and existing connections are replaced with new ones within a few minutes.

The following environment variables map to the following configuration file fields. Each field is documented below.

VariableConfig File Field
MONETR_PG_ADDRESSpostgresql.address
MONETR_PG_PORTpostgresql.port
MONETR_PG_USERNAMEpostgresql.username
MONETR_PG_PASSWORDpostgresql.password
MONETR_PG_DATABASEpostgresql.database
MONETR_PG_TLSpostgresql.tls
MONETR_PG_INSECURE_SKIP_VERIFYpostgresql.insecureSkipVerify
MONETR_PG_CA_PATHpostgresql.caCertificatePath
MONETR_PG_KEY_PATHpostgresql.keyPath
MONETR_PG_CERT_PATHpostgresql.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:

Run Database Migrations
monetr database migrate

To see the current database schema version run the following command:

Database Schema Version
monetr database version