We resolved splitting migration into 2 stages:
We'll do a schema migration only adding the new sender_id column, and do data migration live, and we'll do a second schema migration removing the sender column at a later version.
This needs to be run between both migrations:
Message.distinct.pluck(:sender).each do |sender|
Message.where('sender = ?', sender).update_all sender_id: User.locate!(sender).id rescue nil
end
:dart: Goal
Stop referencing user via uid in messages.
:memo: Details
We resolved splitting migration into 2 stages: We'll do a schema migration only adding the new sender_id column, and do data migration live, and we'll do a second schema migration removing the sender column at a later version.
This needs to be run between both migrations:
:warning: Dependencies
None.
:back: Backwards compatibility
This requires some updates on dependent gems too.
:soon: Future work
None.