Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

How can we make migrations better? #179

Open
jbuck opened this issue Oct 8, 2015 · 4 comments
Open

How can we make migrations better? #179

jbuck opened this issue Oct 8, 2015 · 4 comments
Labels

Comments

@jbuck
Copy link
Member

jbuck commented Oct 8, 2015

Today we had an small amount of downtime when a migration was not run against the production database before pushing the application code to production. How can we prevent this from happening in the future?

@sedge
Copy link
Contributor

sedge commented Oct 8, 2015

I might be wrong, but I thought the point of Knex migrations was to automatically update schemas when they change without losing data. If this is true, we should be able to add that as a step to the deploy process no? Are we using Knex incorrectly?

cc: @ashleygwilliams

@Pomax
Copy link
Contributor

Pomax commented Oct 8, 2015

What is the deployment process right now? It sounds like we're missing the migration step when moving from staging to production. I don't see a postinstall script in the package.json, so it might be that we just need to add a postinstall call for npm run migrate (rather than npm run knex, which runs migrate+seed, the latter of which is not very useful to run every time a prod push happens), so that instance that already have an .env file or heroku vars, with a working database attached, get automigrated.

@jbuck
Copy link
Member Author

jbuck commented Oct 8, 2015

@sedge As we've learned, depends how you code your migrations! :) But generally speaking, yes, migrations should be safe to run at all times. And unsafe migrations should be caught/changed in code review.

@Pomax Heroku auto deploys master to staging and there's a human-pressed promotion button to production

@sedge
Copy link
Contributor

sedge commented Oct 8, 2015

Okay, so what this means is we need to:

  1. Always confirm that modifications to the migration scripts leave them safe
  2. Hook migrations into the promotion process, or stop using heroku pipelines and deploy using travis-ci hooks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants