Sha256: 96cdbbd2ba8993918e509ecadf30165104d81c494b884869c146aded7a1ffd96

Contents?: true

Size: 460 Bytes

Versions: 18

Compression:

Stored size: 460 Bytes

Contents

class PopulateDeploysUser < ActiveRecord::Migration
  def up
    deploys = Deploy.where("deployer IS NOT NULL")
    pbar = ProgressBar.new("deploys", deploys.count)
    user_id_by_email = Hash.new { |hash, email| hash[email] = User.find_by_email_address(email).try :id }
    deploys.find_each do |deploy|
      user_id = user_id_by_email[deploy.deployer]
      deploy.update_column :user_id, user_id if user_id
      pbar.inc
    end
    pbar.finish
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.7.0 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.7.0.beta4 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.7.0.beta3 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.7.0.beta2 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.7.0.beta db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.6.3 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.6.2 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.6.1 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.6.0 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.6 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.5 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.4 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.3 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.2 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.1 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.0 db/migrate/20150902010853_populate_deploys_user.rb
houston-core-0.5.0.beta1 db/migrate/20150902010853_populate_deploys_user.rb