made migration more failure tolerant
This commit is contained in:
parent
e201340bb2
commit
f5488bd032
1 changed files with 8 additions and 4 deletions
|
|
@ -9,9 +9,11 @@ class PhotoStatusMessageAssociationOnGuid < ActiveRecord::Migration
|
|||
|
||||
photos = Post.where(Post.arel_table[:status_message_id].not_eq(nil).and(Post.arel_table[:type].eq('Photo')))
|
||||
photos.each do |photo|
|
||||
if Post.where(:id => photo.status_message_id).exists?
|
||||
status_message = Post.find(photo.status_message_id)
|
||||
photo.update_attributes(:status_message_guid => status_message.guid)
|
||||
end
|
||||
end
|
||||
|
||||
remove_index :posts, [:status_message_id, :pending]
|
||||
add_index :posts, :status_message_guid
|
||||
|
|
@ -25,9 +27,11 @@ class PhotoStatusMessageAssociationOnGuid < ActiveRecord::Migration
|
|||
|
||||
photos = Post.where(Post.arel_table[:status_message_guid].not_eq(nil).and(Post.arel_table[:type].eq('Photo')))
|
||||
photos.each do |photo|
|
||||
if Post.where(:guid => photo.status_message_guid).exists?
|
||||
status_message = Post.where(:guid => photo.status_message_guid).first
|
||||
photo.update_attributes(:status_message_id => status_message.id)
|
||||
end
|
||||
end
|
||||
|
||||
remove_index :posts, [:status_message_guid, :pending]
|
||||
add_index :posts, :status_message_id
|
||||
|
|
|
|||
Loading…
Reference in a new issue