Plugins - Manage Fixtures

StarAdd to favorites

This 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)

  • Currently 3.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Misc. Enhancements

Tags

Comments

Add a comment
Mark 15 May 2008

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.

Mark 15 May 2008

This is really useful plugin. Many thanks for sharing.

e-Jah 22 Feb 2008

Guys, your plugin is awesome !!! I just love you, you saved me !

Thanks !

Paul Flewelling 21 Jan 2008

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('---', '')

Paul Flewelling 21 Jan 2008

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

viktor tron 15 Dec 2007

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

kuahyeow 21 Aug 2007

This is a wonderful plugin. And the fact that it is so small is really a benefit.

Trek 8 Jul 2007

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!

Joshua 2 Jun 2007

As Craig already mentioned, the rating is to low. this excellent plugin saved me a lot of time and worked like a charm.

Kevin Elliott 13 Feb 2007

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.

Kevin Elliott 13 Feb 2007

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.

Craig Knox 5 Feb 2007

I'm not really sure why your rating is so low - I find this tool quite useful. Thanks!

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?