Skip to content

QMS Database

This Database is used for CyVerse QMS service.

Initialize database

Access vm

ssh root@DB_HOST.com

Create required Database

# create qms database with de owner
create database qms with owner de;

Add required extensions

# psql -U postgres
\c de
create extension "uuid-ossp";
create extension "moddatetime";
create extension "btree_gist";
create extension "insert_username";

Populate Database

TODO

Migrate Database

Once a while upon updating the k8s services, we would require to migrate the qms-database, to add the latest database changes.

Clone QMS repo

git clone https://github.com/cyverse/QMS.git
git fetch && git checkout prod
cd QMS

install golang-migrate

These steps are used on Ubuntu debian based OS.

curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | sudo bash
apt-get update
apt-get install -y migrate

# check
migrate -help

Run to migrate QMS database

Note: we are running the /migration directory from QMS

migrate -database postgres://USER:PASSWORD@DB_HOST.com/qms?sslmode=disable -path migrations up

Run to migrate de database (docker container)

Note: our host where the docker container is running is required to have access permissions to the Database.

# clone and navigate to the directory 
# where the /migration folder is located
git clone https://github.com/cyverse/QMS.git
git fetch && git checkout prod
cd QMS

# run docker container and mount the migration directory.
docker run --rm -v $(pwd)/migrations:/migrations --network host migrate/migrate --database "postgresql://USER:PASSWORD@DB_HOST.com:5432/qms?sslmode=disable" -path /migrations up