Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 data_migrations.gemspec
README.md

data_migrations Build Status

class CreateBuilds < ActiveRecord::Migration
  def self.up
    create_table :tests do |t|
      # ...
    end

    migrate_table :builds, :to => :tests |t|
      t.where 'parent_id IS NULL'
      t.move :number
      t.copy :parent_id, :to => :build_id
      t.copy :commit, :result, :to => [:hash, :status]
      t.copy :all

      # t.copy :all, :except => :foo
      # t.exec 'UPDATE foo ...'
      # t.set :source, 'github'
    end
  end

  def self.down
    # revert the whole thing. not sure we can derive this automatically?

    migrate_table :builds, :to => :tests |t|
      t.move :number
      t.copy :build_id, :to => :parent_id
      t.copy :hash, :status, :to => [:commit, :result]
    end

    drop_table :tests
  end
end
Something went wrong with that request. Please try again.