[LRUG] Initial migration for new Rails 4 project using existing postgres db

gvim gvimrc at gmail.com
Wed Mar 16 11:59:44 PDT 2016


I seem to have no luck getting a response from either RubyOnRails irc or 
the Rails Talk mailing list (someone please explain) so excuse me for 
posting here.

I've setup a new Rails 4 project from an existing postgres database and 
didn't have much luck with:

https://medium.com/@kitsched/starting-a-ruby-on-rails-project-from-existing-data-7dda5044c85f#.a0fizbgln

... which resulted in an empty database after `rake:db:reset` and 
incomplete data after `rake db:migrate` which calls 
Rake::Task['db:data:load'].invoke on a data.yml file.

In any case I'm a bit confused about the whole schema vs. data split in 
Rails migrations. Most of what's written refers to the schema and when 
data is referred to it's usually with reference to seeds.rb which is 
really only sample data, not the full data set of an existing db. When 
you're working with an existing db, ie. a full data set, how do you 
manage data within migrations?

My tentative approach is to do away with an initial "create" migration 
and substitute it with the output an initial pg_dump. Will subsequent 
migrations work, assuming there will never be a need to recreate the db 
solely from Rails migrations?

gvim



More information about the Chat mailing list