rake db:schema:dump
This command gives you the schema of a legacy database and you can build a migration for that database off the generated schema.
But if that database had data in it, it would be nice if there was a rake command to retrieve the data in a migration file generated by Rails.
Perhaps I'm dreaming - it's probably asking too much to think that Rails could look at the data in the legacy database and construct a migration for you from the existing data - something like this:
class LoadDefaultData < ActiveRecord::Migration
def self.up
bopeep = User.find_by_username 'bopeep'
BlogPost.create(:title => 'test', :content => 'test', :author_id => bopeep.id, :status => 'ok')
end
def self.down
end
end
Or is there a way?