Sha256: e3151133cd09f555e6c21f134314d2f5d7ec53d9df5a68170f37850b9aa065fc

Contents?: true

Size: 487 Bytes

Versions: 20

Compression:

Stored size: 487 Bytes

Contents

require "progressbar"

class AddHeadShaToProjects < ActiveRecord::Migration
  def up
    add_column :projects, :head_sha, :string

    projects = Project.unretired
    pbar = ProgressBar.new "projects", projects.count

    projects.find_each do |project|
      pbar.inc
      next unless project.repo.exists?

      sha = project.repo.branch("master")
      project.update_column :head_sha, sha
    end

    pbar.finish
  end

  def down
    remove_column :projects, :head_sha
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
houston-core-0.9.2 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.9.1 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.9.0 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.9.0.rc1 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.4 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.3 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.2 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.1 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.0 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.0.pre2 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.8.0.pre db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.7.0 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.7.0.beta4 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.7.0.beta3 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.7.0.beta2 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.7.0.beta db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.6.3 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.6.2 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.6.1 db/migrate/20151202005557_add_head_sha_to_projects.rb
houston-core-0.6.0 db/migrate/20151202005557_add_head_sha_to_projects.rb