Sha256: 817af65530780c503f0648fc933639d55dba0792432797b9078c1efd331f5746

Contents?: true

Size: 758 Bytes

Versions: 120

Compression:

Stored size: 758 Bytes

Contents

class AddRejectRelation < ActiveRecord::Migration
  def up
    Actor.all.each do |a|
      Relation::Reject.default_for(a)
    end

    Tie.
      includes(:relation, :contact, :sender).
      merge(Relation.where(:type => 'Relation::Public')).
      each do |t|
        if t.contact.ties_count != 1
          logger.warn "Public contact #{ t.contact_id } has #{ contact.ties_count }, when expecting 1"
        end

        t.update_attribute :relation_id, t.sender.relation_reject.id
      end
  end

  def down
    Tie.
      includes(:relation, :contact).
      merge(Relation.where(:type => 'Relation::Reject')).
      each do |t|
        t.update_attribute :relation_id, t.sender.relation_public.id
      end

    Relation::Reject.destroy_all
  end
end

Version data entries

120 entries across 120 versions & 4 rubygems

Version Path
social_stream-base-0.9.31 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.8 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.30 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.7 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.29 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.6 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.5 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.28 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.4 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.27 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.3 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.26 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.2 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.25 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.1 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.24 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.12.0 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.23 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.11.8 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.9.22 db/migrate/20110912074426_add_reject_relation.rb