Skip to content

Rails Migration Memory Therapy

codeclimber.blogspot.com
4 pointseVizitei2 comments
On HN

Comments

I know this isn't very Ruby or rails specific, but if you are doing big changes to your db on big datasets and you don't use transactions, you deserve whatever comes your way.

Realize you've fucked up? A quick ROLLBACK TRANSACTION and you are safely back where you started. This is so freaking simple, I can't believe people aren't using it.

This. Model.transaction do ... end is not that hard.

Also, in Rails 2.3 you can do .find_each, which will iterate over each record in 1000-chunk batches.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.