Search code examples
ruby-on-railsrubydatabaseactiverecorddata-migration

Is there a Ruby database migration gem, that helps you move content from an old structure to a new structure?


Are there any Ruby gems/libraries that help you migrate from an old DB structure to a new structure? ActiveRecord migrations do a good job keeping track of a new db structure, but I wonder if there's something that helps you migrate an entire legacy db to a new structure:

transfer_from(:source_table => 'person', :destination_table => 'dudes_and_dudets') do

  from :name, :to => :full_name

  from :dob, :to => :age do |dob|    # this would, for example, load the result  
    (Date.today - dob)/60/60/24/365  # of the block into :age
  end

end

(I realize you could do these transforms just as easily with AR, but I'm hoping the magic library would have many more transforms.

Berns


Solution

  • I've begun working on this.

    If anyone would like to give tips on a better/more idiomatic, or more efficient implementation, please let me know.

    http://github.com/btelles/legacy_migrations

    edit:

    I now have this exact syntax working on the above github repository... plan to add a few rake tasks for mapping the old structure to new ActiveRecord classes, and more transforms...in case anyone's interested.

    It's also on gemcutter/rubygems: gem install legacy_migrations