Reputation: 5435
I need to fix some data inconsistencies in our database, and I'm not so sure if it's considered a bad practice putting that code as a migration (in db/migrations
). Is there a better, more elegant way? Thanks
Upvotes: 1
Views: 124
Reputation: 3407
If it is a one-off execution ( for example backfilling a new field's default value, or changing a data-type), I suggest db/migrations for two reasons :
self.down
)Alternatively, if the script is auditing your data systematically, and new data could potentially have these inconstencies. A rake task would be desirable so you can periodically execute the script.
Upvotes: 1