PostgreSQL
Introduction
PostgreSQL is one of the most widely used open source object-relational databases.
Installation
Information on how to install PostgreSQL.
Ubuntu
Run in the terminal:
sudo apt install postgresql
Windows
Install the database server:
Install the PostgreSQL client pgAdmin.
Client
Connect to PostgreSQL to run management commands on the database server.
Ubuntu
Run in the terminal:
sudo -u postgres psql
Windows
Install and use pgAdmin.
Create User
Run the following command connected to the PostgreSQL client:
create user app_user with password 'S3cR3t';
Create the Database
Run the following command connected to the PostgreSQL client:
create database app_db with owner app_user;
To exit, use the command:
\q
Configure the Database
Connect to the newly created database using the PostgreSQL client application.
Ubuntu
Run the following command in the terminal:
sudo -u postgres psql app_db
Windows
Install and use pgAdmin.
Install the UUID extension
The extension to generate UUIDs must be installed in PostgreSQL.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
Configure the Application
Edit the application's configuration file according to the environment:
config/_development.json
Example of the configuration for PostgreSQL:
{
...
"db": {
"default": {
"engine": "pg",
"port": "5432",
"host": "localhost",
"name": "app_db",
"username": "app_user",
"password": "S3cR3t"
}
},
...
}
Advanced configurations can be used, such as:
{
...
"db": {
"default": {
"engine": "pg",
"port": "5432",
"host": "localhost",
"name": "app_db",
"username": "app_user",
"password": "S3cR3t",
"maximumPoolSize": 100,
"minimumIdle": 1,
"idleTimeout": 10000,
"maxLifetime": 60000
}
},
...
}