Database Configuration

monetr now configures it's database connection via the database config block. This is to enable more database backends in the near future. The long term goal is for monetr to support (and default to) SQLite as the database backend for new installations. To that end, this is monetr's new method of configuring a database connection for the server.

config.yaml
database:
  kind: postgresql # Can only be postgresql at the moment
  postgreSql: { ... } # PostgreSQL configuration

At the moment this configuration is a no-op, however following the v1.19.0 you will start receiving warnings if this block is not configured. In a following release monetr will switch over to using this config block instead of the PostgreSQL config block that exists today.

PostgreSQL Configuration

Officially monetr supports PostgreSQL version 16 and higher.

config.yaml
database:
  # ...
  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_ADDRESSdatabase.postgresql.address
MONETR_PG_PORTdatabase.postgresql.port
MONETR_PG_USERNAMEdatabase.postgresql.username
MONETR_PG_PASSWORDdatabase.postgresql.password
MONETR_PG_DATABASEdatabase.postgresql.database
MONETR_PG_TLSdatabase.postgresql.tls
MONETR_PG_INSECURE_SKIP_VERIFYdatabase.postgresql.insecureSkipVerify
MONETR_PG_CA_PATHdatabase.postgresql.caCertificatePath
MONETR_PG_KEY_PATHdatabase.postgresql.keyPath
MONETR_PG_CERT_PATHdatabase.postgresql.certificatePath

SQLite Configuration

Coming Soon!

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