Skip to content

Instantly share code, notes, and snippets.

@notjrbauer
Last active August 29, 2015 14:26
Show Gist options
  • Save notjrbauer/611e8fba07a1b2603f25 to your computer and use it in GitHub Desktop.
Save notjrbauer/611e8fba07a1b2603f25 to your computer and use it in GitHub Desktop.

Deploying and migrating, etc

Deployment

Urls

DB urls (see aptible dashboard)

  • QA : coast-to-coast-qa (will change to match other naming schemes)
  • RC : md-mongo-rc

QA

RC / Stage

Deploying

Clients

When deploying any of the clients to RC, please review the deploy.sh file to get a better understanding as to what specific ENV_VARS are needed. See andrew if you have any questions.

Run EAZE_GIT_PASSWORD=yourpwhereplease NODE_ENV=RC ./deploy.sh

For md-client, you must specific doctor / patient through the ENV_VAR 'APP' (APP=doctor).
For md-admin, you should just be able to run the aforementioned.

Any code pushed to master will end up on the QA URL's! Please QA before pushing to RC, and communicate with everyone in slack before and after producing an RC.

Backends

In order to deploy the md-server / md-socket-server to RC, one must simply push to the aptible-rc remote.

To find the remotes

  1. go into the aptible dashboard -> coast-to-coast-qa -> and find md-server-rc / md-socket-server-rc
  2. add remote by: git remote add aptibleRC git@whatever.aptible.com:somethingfromthedashboard.git
  3. git push aptibleRC master --force

QA Deployment is automagically done through circle. Just push to the master branch, and if you have some nice tests - you get a nice QA.

Migrations mon

Inside of md-server you'll find a migrations folder.

Creating Migrations

Just run node ./node_modules/.bin/mongo-migrate -runmm create patients-add-email to create the patients-add-email migration.

Please keep the naming schema to model-action-property

Definging Migrations

Up refers to the introduction of something new to the schema, or a change. Please try to make a file per change per property!

Down refers to a revert (you make janky migration, define down to go back to the previous state). Define the exact opposite of what up tries to accomplish.

Running Migrations

Important There's a default-config.json that specifies the DB which the migrations will act upon.
Make sure you define it per your db you're operating on. All the information like host, pw, etc can be found on aptible.

Example, you tunnel to an aptible db through aptible db:tunnel md-mongo-rc and it assigned you port 12345

your config should look like:

{
  mongoAppDb: {
    host: 'localhost',
    port: '12345',
    username: 'whatever is in aptible',
    password: 'whatever is in aptible'
  }
}

For up: node ./\node_modules/\mongodb-migrate -runmm up (or npm run migrate)
For down: node ./\node_modules/\mongodb-migrate -runmm down

For any other migration questions, refer to mongo-migrate

Importing things locally in case you're afraid of doing it on prod >)

Cloning DB's The easiest / most sane way of replicating a db is through cloning.

  1. Must first have a destination and a source.
  2. start mongo in your destination
  3. enter db.copyDatabase('the source db name', 'the destination db name', 'ip of source': 'port of source', 'password', 'MONGODB-CR')

Example This copies db from 127.0.0.1:63488 and places it locally under the testing name

db.copyDatabase('db', 'testing', '127.0.0.1:63448', 'aptible', 'passwords are fun when you share with everyone', 'MONGODB-CR')

EXPORTING JSON FILES (When the above doesn't work) Have your aptible tunnel running...

Export the doctors table by: mongoexport --host 127.0.0.1:APTIBLEPORT --username aptible --password 'SOMEPASSWORD --authenticationDatabase db --collection doctors --db db --out doctors.json

IMPORT JSON FILES
Have mongodb running locally, make sure you arent connected to aptible

Import a doctor table

doctors.json```  

You can also run the above on any non-local db by specifiying a host, port, username, and password.  

***All table names must be pluralized***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment