Rails Development Database Setup Without Migrations

I think a lot of Rails developers have been using the db:migrate Rake task to setup new development databases. The problem with this is that over time migrations tend to grow out of sync with the code, especially if you use model classes in your migrations (which in some cases can be very convenient and DRY). A more robust approach to setting up a development database is to load the schema and seed it with data like the db:setup Rake task in Rails 3 does. Now there are a couple of issues for us in using this approach. First we are not on Rails 3 yet (obviously), second we use schema format SQL so the db:schema:load task doesn’t work (see my patch for fixing this), and third, we don’t have a proper db/seed.rb file yet for setting up all the data that so far has been set up by our migrations. To work around these issues I came up with a task like this. The db/development_data.sql file was created by invoking the db:structure:dump task and exchanging the -s option to pg_dump with -a for data only.

Posted by peter Posted in Ruby on Rails Tagged
  • http://www.pedalroom.com Christian Coomer

    How do you deal with unit tests without migrations? My new rails app complains because I setup my DB without migrations.

blog comments powered by Disqus