SeedDumper
Seed dumper is a simple plugin that adds a rake task named db:seed:dump. Forked and simplified from seed_dump. If you require
It allows you to create a db/seeds.rb from your existing data in the database. When there is no data in the database it will generate empty create statements.
It mainly exists for people who are too lazy writing create statements in db/seeds.rb themselves and need something (seed_dump
) to dump data from the table(s) into seeds.rb
Example Usage
Dump all data directly to db/seeds.rb:
rake db:seed:dump
Result:
$ cat db/seeds.rb
# Autogenerated by the db:seed:dump task
# Do not hesitate to tweak this to your needs
products = Product.create([
{ :category_id => 1, :description => "Long Sleeve Shirt", :name => "Long Sleeve Shirt" },
{ :category_id => 3, :description => "Plain White Tee Shirt", :name => "Plain T-Shirt" }
])
users = User.create([
{ :id => 1, :password => "123456", :username => "test_1" },
{ :id => 2, :password => "234567", :username => "tes2" }
])
Note on Patches/Pull Requests
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Kevin Edwards, released under the MIT license