Thursday, October 4, 2007

Copy data between databases using script/console

A quick blog about how easy it is to copy data between databases using script/console.
For e.g. I copy data from production server to the development server below:

% script/console production -s
> projects = Project.find(:all)
> ActiveRecord::Base.establish_connection(:development)
> projects.each {|p| Project.create p.attributes}
> CtrlD

No comments: