Sha256: 78da0ca67247f9aad98135a06d0dc02002daf51d2a4e7174c6163dbde87637fe

Contents?: true

Size: 600 Bytes

Versions: 14

Compression:

Stored size: 600 Bytes

Contents

class AddColumnModeratorIdToGroup < ActiveRecord::Migration
  def up
    add_column :groups, :moderator_id, :integer

    Group.all.each do |group|

      if defined?(ThinkFeelDoDashboard::Moderator)
        moderator = ThinkFeelDoDashboard::Moderator.where(group_id: group.id).first
      else
        moderator = nil
      end

      if moderator
        group.update_attributes(moderator_id: moderator.user_id)
      else
        group.update_attributes(moderator_id: User.first.id)
      end
      group.save
    end
  end

  def down
    remove_column :groups, :moderator_id, :integer
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.2.1 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.2.0.beta1 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.21 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.20 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.19 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.18 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.17 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.16 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.15 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.14 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.13 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.12 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.11 db/migrate/20141215203425_add_column_moderator_id_to_group.rb
think_feel_do_dashboard-1.1.10 db/migrate/20141215203425_add_column_moderator_id_to_group.rb