Sha256: abb874577f6a15ae36338d3a83b64e383879739b7137498235da0ca110c4f205

Contents?: true

Size: 472 Bytes

Versions: 1

Compression:

Stored size: 472 Bytes

Contents

class LinkCommitsAndReleases < ActiveRecord::Migration
  def up
    create_table :commits_releases, :id => false do |t|
      t.references :commit, :release
    end
    
    add_index :commits_releases, [:commit_id, :release_id], :unique => true
    
    Commit.find_each do |commit|
      release = Release.find_by_id(commit.release_id) if commit.release_id
      commit.releases << release if release
    end
  end

  def down
    drop_table :commits_releases
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 db/migrate/20130806143651_link_commits_and_releases.rb