Rails Plugin: DBSerialize

People who have worked with a small team on a project know the problems: "The late night dudes have changed the database and now the live server is unuseable for the early risers." Few phonecalls later - Ey man next time please email around the latest sql dump if you do some changes.

Though Rails does the best to keep you on track by providing a migration mechanism at a certain point at the development you want to be able to share the contents of the development database, not only the schema.

That's why we created a little plugin that adds two rake tasks:

RUBY:
  1. rake db:serialize:save

Will create fixtures from all the database data and store each table into a corresponding yaml file.

RUBY:
  1. rake db:serialize:load

Will load all fixtures into the database (erasing your existing record so be careful).

To only export certain tables, set the FIXTURES environment variable to a list
of table names seperated by commas:

RUBY:
  1. FIXTURES="users,posts" rake db:serialize:save

INSTALL

You can easily add it to your rails project (from your rails app root):

CODE:
  1. git submodule add git://github.com/janv/dbserialize.git vendor/plugins/dbserialize

or get it from github through git

CODE:
  1. git clone git://github.com/janv/dbserialize.git vendor/plugins/dbserialize

or you can keep it fresh with

CODE:
  1. git submodule init
  2. # or
  3. git submodule update

or browse the repository.

COPYRIGHT

All code is © 2007-2009 by Jan Varwig and is released under the MIT License. Feel free to email (contact mofoat 9elements.com) us with any questions or feedback or drop us a line on Twitter.

I LIKE THIS - CAN I HELP

Yes - add this to del.icio.us or digg us or in case you're a maniac coder, checkout the repository and add more features.