Sha256: 940f0fd23fbf326129ac2d85ff0271499610bfc3eff326bd7f9d4128c9ffa804

Contents?: true

Size: 1.33 KB

Versions: 49

Compression:

Stored size: 1.33 KB

Contents

class GroupTitleAndDescriptionInActivityObject < ActiveRecord::Migration
  def up
    ao_ts = ActivityObject.record_timestamps
    ActivityObject.record_timestamps = false

    change_table :activity_objects do |t|
      t.string :title, :default => ""
      t.text :description
    end

    ActivityObject.reset_column_information

    # Fix 'comments' table
    c_ts = Comment.record_timestamps
    Comment.record_timestamps = false

    Comment.all.each do |c|
      # Remove comments that are not properly deleted
      # https://github.com/ging/social_stream/issues/213
      if c.activity_object.activities.blank?
        c.destroy
        next
      end

      c.activity_object.description = c.read_attribute(:text)
      c.save!
    end
    change_table :comments do |t|
      t.remove :text
    end
    Comment.reset_column_information
    Comment.record_timestamps = c_ts

    # Fix 'posts' table
    p_ts = Post.record_timestamps
    Post.record_timestamps = false

    Post.all.each do |p|
      p.activity_object.description = p.read_attribute(:text)
      p.save!
    end
    change_table :posts do |t|
      t.remove :text
    end
    Post.reset_column_information
    Post.record_timestamps = p_ts

    ActivityObject.record_timestamps = ao_ts
  end

  def down
    raise ActiveRecord::IrreversibleMigration # Due to trans-gem oddities
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
social_stream-0.29.0 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.23.0 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.28.4 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.22.4 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.28.1 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.22.1 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.28.0 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.22.0 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.27.3 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.27.2 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.21.2 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.27.1 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.21.1 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.27.0 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.21.0 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.26.2 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.20.2 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.26.1 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-base-0.20.1 db/migrate/20120208135718_group_title_and_description_in_activity_object.rb
social_stream-0.26.0 base/db/migrate/20120208135718_group_title_and_description_in_activity_object.rb