Sha256: d830a37d5273c2cfd854e3166263226ecaf694b264cf20ab17025d3beb868e44
Contents?: true
Size: 909 Bytes
Versions: 7
Compression:
Stored size: 909 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 %( 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 %( UPDATE #{table} SET subscribed_users = '#{subscribed_users_set.to_yaml}' WHERE id = #{entity['id']} ) end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems