Upgrade Directory Database

When installing an upgrade you will on some occasions need to upgrade the directory database before the new version of the directory service (mops-dir) can be started.

Preconditions

Before running the below upgrade steps you need to make a backup of the current database. Any of the below methods may be used:

  1. Shut down the database server and make a file system backup of the folder that contains the postgres database (usually {system-root}/data/db/…).
  2. Export the database using pg_dump. Make sure you test the exported database by importing it to a new database.
  3. Make a copy of the database to a different name. Use pgAdmin4, pg_dump/sql to create a database copy.

Step 1 - Read Upgrade Notes

Upgrade notes provided in the release package may include instructions for a specific release. Read these instructions from the version installed to the version about to be installed.

Step 2 - Database Schema Upgrade

The first step when upgrading the database is to upgrade the database schema. This will add any new tables, views or other database changes introduced in the new version.

Run database upgrade scripts, one by one, from the version installed to the last version provided in the package.

NOTE: Before running the script, make sure that the schema name in variables.pgsql (DIRDB_SCHEMA) matches the schema name in the database. If not, update the name of the schema in variables.pgsql.

psql --file changescripts/directory-db-upgrade.2.pgsql  postgres://{username}:{password}@{host}:{port}/{databasename}
psql --file changescripts/directory-db-upgrade.3.pgsql  postgres://{username}:{password}@{host}:{port}/{databasename}

Check the console output after each step to ensure that the upgrade scripts complete without errors.

Step 3 - Update Directory Metadata

The directory service database contains metadata, display components, displays and dashboards that are part of the distribution. This data may be updated in new releases. Run the following command to update metadata.

psql --file seed_directory_db.pgsql postgres://{username}:{password}@{host}:{port}/{databasename}

This script adds missing metadata and updates existing metadata.