Sha256: 8f9a4bebfb294416038554cc552c491e852062ded7e8e8f7c96234edcb40177c

Contents?: true

Size: 597 Bytes

Versions: 17

Compression:

Stored size: 597 Bytes

Contents

class AddProjectIdToCommits < ActiveRecord::Migration
  def up
    add_column :commits, :project_id, :integer

    Commit.reset_column_information
    Commit.find_each do |commit|
      release = commit.release

      if release.nil?
        commit.delete
        Rails.logger.warn "Deleting commit ##{commit.id} (#{commit.attributes.inspect})"
        next
      end

      commit.update_column(:project_id, release.project_id)
    end

    change_column_null :commits, :project_id, false

    add_index :commits, [:project_id]
  end

  def down
    remove_column :commits, :project_id
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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