Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.93 KB

README.md

File metadata and controls

43 lines (30 loc) · 1.93 KB

Running Warrant with PostgreSQL

This guide covers how to set up PostgreSQL as a datastore for Warrant.

Note: Please first refer to the development guide to ensure that your Go environment is set up and you have checked out the Warrant source or downloaded a binary.

Install PostgreSQL

Install and run the PostgreSQL Installer for your OS to install and start PostgreSQL. For MacOS users, we recommend installing PostgreSQL using homebrew.

Warrant configuration

The Warrant server requires certain configuration, defined either within a warrant.yaml file (located within the same directory as the binary) or via environment variables. This configuration includes some common variables and some PostgreSQL specific variables. Here's a sample config:

Sample warrant.yaml config

port: 8000
logLevel: 1
enableAccessLog: true
autoMigrate: true
authentication:
  apiKey: replace_with_api_key
datastore:
  postgres:
    username: replace_with_username
    password: replace_with_password
    hostname: localhost
    database: warrant
    sslmode: disable

Note: You can create a databases via the postgres command line and configure it as the database attribute under datastore.

Running db migrations

Warrant uses golang-migrate to manage sql db migrations. If the autoMigrate config flag is set to true, the server will automatically run migrations on start. If you prefer managing migrations and upgrades manually, please set the autoMigrate flag to false.

You can install golang-migrate yourself and run the PostgreSQL migrations manually:

migrate -path ./migrations/datastore/postgres/ -database postgres://username:password@hostname/warrant up