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-0.19.2 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.14.2 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.19.1 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.14.1 db/migrate/20110912074426_add_reject_relation.rb
vkhater-social_stream-0.16.3.3 base/db/migrate/20110912074426_add_reject_relation.rb
vkhater-social_stream-base-0.11.2 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.19.0 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.14.0 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.18.2 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.13.2 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.18.1 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.13.1 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.18.0 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.13.0 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.17.1 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.12.1 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.17.0 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.12.0 db/migrate/20110912074426_add_reject_relation.rb
social_stream-0.16.3 base/db/migrate/20110912074426_add_reject_relation.rb
social_stream-base-0.11.2 db/migrate/20110912074426_add_reject_relation.rb