rake db:schema:dump
This command gives you an outdated database schema, and you can create a migration for this database from the generated schema.
But if there was data in this database, it would be nice if there was a rake command to retrieve the data in the migration file generated by Rails.
Maybe I’m dreaming - maybe it’s too much to think that Rails can look at the data in the old database and create a transfer from existing data for you — 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?
source
share