Skip to main content

Database

Data is stored in MongoDB via Mongo Atlas Your local docker env will have a database called pixwel-dev pre-installed, but that’s not super useful because it’s not got real data in it.

Getting real data into your development environment

Log into your mongo container VERSION=latest docker-compose exec mongo bash then run cd utils. In this directory you’ll find two scripts to clone the staging or production database locally. You can run either db-copy-prod-to-local.sh or db-copy-staging-to-local.sh. Otherwise you can build your own custom script. The following template is given as example:
#!/bin/bash
colls=( asset_types assets billingrates downloads_reportables email_jobs events fs.chunks fs.files groups imports offlines permissions permissions_cache previews projects shares studios subscriptions tags territories tokens translations users work_requests work_requests_reportables )

for c in ${colls[@]}
do
  mongodump --host <HOST> --db <DB> --port <PORT> --username <USERNAME> --password <PASSWORD> --collection $c
done

mv dump/<DB> dump/pixwel-dev

mongorestore --drop
You will need to supply values for <DB>, <HOST>, <PORT>, <USERNAME> and <PASSWORD>. This will pull down the data, then pull the dump into your local mongodb. Alternatively, you can sync a snapshot of the most recent 5,000 documents from each collection from any existing database:
vagrant ssh
mongo <host>:<port>/<database> -u <username> -p <password> /opt/pixwel/pixwel-api/_build/bin/mongo-sync.js
You’ll then want to populate the search index:
cd /opt/pixwel/pixwel-api
libraries/lithium/console/li3 index-rebuild

Running Migrations

Migrations, stored in /api/_build/migrations, are not currently automated and should be run manually. Run a command like: mongo <host> <credentials> _build/migrations/<file>.js Please ensure your migrations are idempotent.
TODO There is a command to automatically flag deployments to master (not merged at the time of writing).

Back to docs index | Next page in recommended reading order >>