PostgreSQL Database Backend
A PostgreSQL databse is utilized to prevent duplicate DSP transactions by creating, getting, and updating service events as needed. An external database can be set by ensuring the node_env variable in the config.toml file is set to production. The database settings may be specified with the url variable, e.g., postgres://user:[email protected]:5432/dbname.

config.toml:

1
[database]
2
​
3
# url syntax: postgres://user:[email protected]:5432/dbname, only necessary for production
4
url = "postgres://user:[email protected]:5432/dbname"
5
​
6
# production (uses above database_url for database)
7
node_env = "production"
Copied!
1
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
2
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list
3
sudo apt update
4
sudo apt -y install postgresql-12 postgresql-client-12
Copied!

Setup database and user

1
sudo su - postgres
2
psql
3
CREATE DATABASE dsp;
4
CREATE USER dsp WITH ENCRYPTED PASSWORD 'Put-Some-Strong-Password-Here';
5
GRANT ALL PRIVILEGES ON DATABASE dsp to dsp;
Copied!
For how to wipe the database, see here​