Sha256: 57fe571242d575ca812a26d5a94c5fc99cf4a9d339d5ad4d4464cf74b72081ab

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

# data\_migrations [![Build Status](https://secure.travis-ci.org/svenfuchs/data_migrations.png)](http://travis-ci.org/svenfuchs/data_migrations)

    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_migrations-0.0.1 README.md