Chatwoot/db/migrate/20200206180408_add_contact_to_message.rb
Pranav Raj S 272c481464
Feature: Create conversations from Tweets (#470)
* Feature: Add tweets to conversations
2020-02-09 15:47:48 +05:30

12 lines
338 B
Ruby

class AddContactToMessage < ActiveRecord::Migration[6.0]
def change
add_reference(:messages, :contact, foreign_key: true, index: true)
::Message.all.each do |message|
conversation = message.conversation
next if conversation.contact.nil?
message.update!(contact_id: conversation.contact.id)
end
end
end