Question

I'm missing something here.

I just fixed a bug on the production state of my app. When I merge it to my development state, it works very well (locally and remotely).

But I really don't know how to get my local machine to my production state, since the db state has changed since then.

Which means I'm about to push to staging a modif I haven't even tested locally.

What's the best practice in this situation?

  • To have multiple local db states by creating more local environments?
  • To rollback my db to the previous state? (How?)
  • To reset my local environment accordingly?
  • To "save" the db state when push to staging/prod to be able to restore when in this situation?
  • Anything else?

Feels like this should be routine for every app manager, but I really can't see how to deal with this, and find rails migrations not so handy at the moment...

Thanks

Was it helpful?

Solution

To get your local database to the same structure as what you have in production:

First get a local checkout of the branch or tag that's deployed to production.

rake db:test:prepare
rake test # or rake spec

That should clean out your test database, and then recreate it according to your db/schema.rb, which should be the same schema you have in prod. Assuming that you first wrote a failing test, then fixed the bug and watched the test pass, your tests should now be passing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top