dwyl / node-postgres-migrations

Running migrations on node postgres
2 stars 2 forks source link

A basic step by step for running migrations in node postgres #1

Open naazy opened 7 years ago

naazy commented 7 years ago

@sohilpandya has requested that we share our knowledge on running migrations in node postgres to make it easier for other teams to get their migrations up and running

Linked to https://github.com/emfoundation/ce100-app/issues/652

sohilpandya commented 7 years ago

Really appreciate this @naazy ❤️

Here is a step by step process of running a migration as far as I understand (it's similar to what's already present in #2)

The caveat here is how does one know if a migration script has been run before?

So the above process is actually:

naazy commented 7 years ago

That's correct @sohilpandya. However, you should be able to just copy the callMigrations.js and migrations.js and this will carry out all of the migrations functionality you mentioned above (including creating the migrations table in the db). Also you don't need a postinstall.js, literally just a 'postinstall' in your package.json: so Heroku knows to run the migration after npm installing e.g.

postinstall: 'npm run migrations' (like we have in the package.json in this repo)

I will make the steps in the PR clearer!