Database Configuration
This document describes how to configure PostgreSQL for Noflux.
Database Installation ¶
The first step is to install PostgreSQL with your package manager.
For example, on Debian it’s simple as typing this command:
sudo apt install postgresql postgresql-contrib
Database Configuration ¶
Here an example from the command line:
# Switch to the postgres user
$ sudo -u postgres -i
# Create a database user for Noflux
$ createuser -P noflux
Enter password for new role: ******
Enter it again: ******
# Create a database for noflux that belongs to our user
$ createdb -O noflux noflux
# Create the extension hstore as superuser
$ psql noflux -c 'create extension hstore'
CREATE EXTENSION
Enabling HSTORE extension for Postgresql
Creating Postgresql extensions requires the SUPERUSER
privilege.
Several solutions are available:
- Give
SUPERUSER
privileges to the noflux user only during the schema migration:
ALTER USER noflux WITH SUPERUSER;
-- Run the migrations (noflux -migrate)
ALTER USER noflux WITH NOSUPERUSER;
- You could create the hstore extension with another user that have the
SUPERUSER
privileges before running the migrations.
sudo -u postgres psql $NOFLUX_DATABASE
> CREATE EXTENSION hstore;
Note that if you use Debian or Ubuntu, you might have to install the postgresql-contrib
package to activate the HSTORE
extension.
Recent versions of Noflux non longer uses the HSTORE
extension but it still required to run the SQL migrations.
Database Connection Parameters ¶
Noflux uses the Golang library pq to communicate with PostgreSQL. The list of connection parameters are available on this page.
The default value for DATABASE_URL
is user=postgres password=postgres dbname=noflux sslmode=disable
.
You could also use the URL format postgres://postgres:postgres@localhost/noflux?sslmode=disable
.
net/url: invalid userinfo
.
To avoid this issue, do not use the URL format for DATABASE_URL
, or make sure the password is URL encoded.