diff --git a/db/migrate/20110527135552_photo_status_message_association_on_guid.rb b/db/migrate/20110527135552_photo_status_message_association_on_guid.rb index 81ae491c8..19f7105e3 100644 --- a/db/migrate/20110527135552_photo_status_message_association_on_guid.rb +++ b/db/migrate/20110527135552_photo_status_message_association_on_guid.rb @@ -3,10 +3,10 @@ class PhotoStatusMessageAssociationOnGuid < ActiveRecord::Migration attr_accessible :id, :guid, :status_message_id, :status_message_guid self.inheritance_column = :_type_disabled end - + def self.up add_column :posts, :status_message_guid, :string - + ActiveRecord::Base.record_timestamps = false photos = Post.where(Post.arel_table[:status_message_id].not_eq(nil).and(Post.arel_table[:type].eq('Photo'))) photos.each do |photo| @@ -15,17 +15,18 @@ class PhotoStatusMessageAssociationOnGuid < ActiveRecord::Migration photo.update_attributes(:status_message_guid => status_message.guid) end end - + + remove_index :posts, [:status_message_id] remove_index :posts, [:status_message_id, :pending] add_index :posts, :status_message_guid add_index :posts, [:status_message_guid, :pending] - + remove_column :posts, :status_message_id end def self.down add_column :posts, :status_message_id, :integer - + ActiveRecord::Base.record_timestamps = false photos = Post.where(Post.arel_table[:status_message_guid].not_eq(nil).and(Post.arel_table[:type].eq('Photo'))) photos.each do |photo| @@ -34,11 +35,12 @@ class PhotoStatusMessageAssociationOnGuid < ActiveRecord::Migration photo.update_attributes(:status_message_id => status_message.id) end end - + remove_index :posts, [:status_message_guid, :pending] + remove_index :posts, :status_message_guid add_index :posts, :status_message_id add_index :posts, [:status_message_id, :pending] - + remove_column :posts, :status_message_guid end end