mumuki / mumuki-domain

💡 Mumuki's domain model
GNU Affero General Public License v3.0
1 stars 0 forks source link

Chore reference message sender via id - Stage 1 #248

Closed julian-berbel closed 3 years ago

julian-berbel commented 3 years ago

: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:

Message.distinct.pluck(:sender).each do |sender|
  Message.where('sender = ?', sender).update_all sender_id: User.locate!(sender).id rescue nil
end

:warning: Dependencies

None.

:back: Backwards compatibility

This requires some updates on dependent gems too.

:soon: Future work

None.

flbulgarelli commented 3 years ago

Looks awesome!!!