Skip to content

Heimdall Heroku Documentation

George M. Dias edited this page Jul 26, 2024 · 4 revisions

Heimdall Heroku Database Maintenances

Heimdall is hosted in Heroku, there are two instances, one for staging, and another for production. Both instances use the Heroku Postgres add-on where Heimdall Server stores its contents. If there is a need to do any database maintenances, it can be accomplished locally using the appropriate Heroku Postgres credentials.

Database Exceeds Size Limit

If Heroku notifies that the database size limit (based on the PLAN being used - we are using essential-0, it has a limit of 1GB storage) is or has been exceeded, follow these procedures to reduce its size.

NOTES:
PGBackups stores backups in a compressed binary format. The backups include commands to recreate indexes instead of storing the indexes themselves.
The backups are store in Heroku Datastores for the database. The mitre-heimdall datastore is located here
Reset Database - resets the database to its originally-provisioned state, deleting all data inside it. This action may require that the session table be created manually, see How to Create the session Table

How to get Heimdall Heroku Postgres Credentials

Credentials for Heroku-Postgres can be retrieved as follows:

Get Heroku-Postgres Credentials from Hosting Site

Connect to the Heroku hosting site, navigate to the appropriate project, select the appropriate deployed instance (e.g., staging or prod), on the provided dashboard select (click) on the Heroku-Postgres link ( image) to open the Datastore dashboard. On the Datastore dashboard select the settings link and click on the View Credentials button

image

The provided values for the following fields are used to establish a connection to the database: Host, Database, User, Port, Password

See Use pgAdmin4 to Connect to Heimdall Heroku Postgres Instances for establishing a connection to the database.

Get Heroku-Postgres Credentials from Heroku CLI

To retrieve the database credentials we need to install The Heroku CLI and Connect to Heroku via Heroku CLI.

Next use the Heroku CLI to retrieve the connection information for a hosting Heroku-Postgres database.

To get the credential for the mitre-heimdall staging instance use: heroku pg:credentials:url DATABASE -a mitre-heimdall-staging

To get the credential for the mitre-staging production instance use: heroku pg:credentials:url DATABASE -a mitre-heimdall

See Connecting to Heroku Postgres for additional information

Connect to Heroku via Heroku CLI

If operating within a restrictive network environment an organization chain certificate may be needed. After obtaining the necessary certificate create an environment variable called NODE_EXTRA_CA_CERTS and set it to point to the certificate

Test the connection by using the CLI: heroku login

For additional information see Quick Start: Heroku Connect CLI

Use pgAdmin4 to Connect to Heimdall Heroku Postgres Instances

The pgAdmin4 from PostgreSQL Tools can be use to establish a connection to the Heimdall Heroku Database. Use the output of the heroku pg:credentials:url CLI command to obtain the necessary information to add a server to pgAdmin4.

Follow the instruction below to setup a connection to a Heroku Postgres.

image

image

image

image

Reset the Database

Connect to the Heroku hosting site, navigate to the appropriate project, select the appropriate deployed instance (e.g., staging or prod), on the provided dashboard select (click) on the Heroku-Postgres link ( image) to open the Datastore dashboard. On the Datastore dashboard select the settings link and click on the Reset Database button. image

How to Create the session Table

To manually create the session table connect to the database using pgAdmin4 open a Query Tool panel and invoke this SQL command:

CREATE TABLE public."session"( sid character varying(255) NOT NULL, sess json NOT NULL, expire timestamp with time zone NOT NULL, CONSTRAINT session_pkey PRIMARY KEY(sid) );

Clone this wiki locally