Sha256: a3c6cc427df45709705125309abe733905e16a7d097fa793ad8a47b54b075c2b
Contents?: true
Size: 895 Bytes
Versions: 14
Compression:
Stored size: 895 Bytes
Contents
class ChangeFurtherSubscribedUsersToSet < ActiveRecord::Migration def up # Change the other tables that were missing from the previous migration %w(campaigns opportunities leads tasks accounts).each do |table| entities = connection.select_all %Q{ SELECT id, subscribed_users FROM #{table} WHERE subscribed_users IS NOT NULL } puts "#{table}: Converting #{entities.size} subscribed_users arrays into sets..." unless entities.empty? # Run as one atomic action. ActiveRecord::Base.transaction do entities.each do |entity| subscribed_users_set = Set.new(YAML.load(entity["subscribed_users"])) connection.execute %Q{ UPDATE #{table} SET subscribed_users = '#{subscribed_users_set.to_yaml}' WHERE id = #{entity["id"]} } end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems