Plugins - Manage Fixtures
Add to favoritesThis plugin is a super lightweight tool used to export data into the test/fixtures directory.
So if you want to export all your data from your production server into your development environment, this will simplify the process without having to load up your database manager.
[%] rake db:fixtures:export_all RAILS_ENV=development [%] rake db:fixtures:load
USAGE
Create YAML test fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override.
rake db:fixtures:export_all
Create YAML test fixtures for a specific table(s) from data in an existing database. Defaults to development database. Set RAILS_ENV to override.
rake db:fixtures:export_for_tables TABLES=foo,bar
Create YAML text fixtures based on a specific SQL query
rake db:fixtures:export_using_query SQL="select * from foo where id='bar'" FIXTURE_NAME=foo
AUTHORS
Chris McGrath Nathaniel Brown - nshb@inimit.com
BUGS
Please report any bugs or feature enhancements to http://dev.toolbocks.com
Chris McGrath, Nathaniel Brown
http://svn.toolbocks.com/plugins/manage_fixtures/
Rails' (MIT)
Misc. Enhancements

I used this to migrate from sqlite3 to mysql but the boolean fields didn't get migrated. They seemed to be returned to the default values. Luckily I didn't have too many to correct.
This is really useful plugin. Many thanks for sharing.
Guys, your plugin is awesome !!! I just love you, you saved me !
Thanks !
Forgot the gsub that I'm using to remove the delimiters that are placed between each yaml record when writing them in this way.
file.write hash.to_yaml.gsub('---', '')
Hey, I really like the plugin.
My only comment is that I have some large "static" tables that I wanted written to yaml in the correct order.
I quickly changed the method that writes the yaml. Maybe a more succinct way to do this, but it works for me :-) Cheers Paul
def writeyamlfixturesto_file(sql, fixturename) i = "000" File.open("#{RAILSROOT}/test/fixtures/#{fixturename}.yml", 'w' ) do |file| data = ActiveRecord::Base.connection.select_all(sql) data.each do |record| hash = Hash.new hash["#{fixturename}#{i.succ!}"] = record file.write hash.to_yaml end end end
The rating might be low, cause the plugin is a bit buggy for import. It breaks on serialized values and didn't work for me for inherited models either single table or not.
However, I had no problem using the rake db:fixtures:load TABLES=... builtin task for import and this plugin for export.
A very valueble addition to fixture management would be to bootstrap fixtures (write out empty fixtures with attributes) for all db tables. see the annotate_models plugin
This is a wonderful plugin. And the fact that it is so small is really a benefit.
Great plugin - makes adding new a test data seem fun compared to the old "keep switching files to make sure I get my foreign keys right" method. If you're a fan of test data, get this plugin!
As Craig already mentioned, the rating is to low. this excellent plugin saved me a lot of time and worked like a charm.
I have solved the problem with the tally. My solution was to pull the increment code out of the if statement that contains the execute. ActiveRecord::Base.connection.execute() does not return anything, so the condition is never true normally.
All of my imports show "Total of my_objects records imported successfully" --- It does not seem to keep track of how many records actually get imported. I am using this under Rails 1.1.6. Has anyone seen this before? I was unable to discover why it is not storing the count to the success hash properly.
I'm not really sure why your rating is so low - I find this tool quite useful. Thanks!