Approaches to data migration on Rails applications

I think following these 2 points is critical, or you will eventually end up with a big mess.

  1. Avoid models in migrations. Models will change, and your older migrations will break. Call execute with raw SQL instead.
  2. If you really really want to use models, you can define narrow-purpose models inside your migrations. Here’s a guide on this practice.