Description
Seed Dump is a Rails 4 and 5 plugin that adds a rake task named db:seed:dump.
It allows you to create seed data files from the existing data in your database.
You can also use Seed Dump from the Rails console. See below for usage examples.
Note: if you want to use Seed Dump with Rails 3 or earlier, use version 0.5.3.
Seed dump alternatives and similar gems
Based on the "Database Tools" category.
Alternatively, view Seed dump alternatives based on common mentions on social networks and blogs.
-
Database Cleaner
Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing. -
Lol DBA
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts. -
Seed Fu
Advanced seed data handling for Rails, combining the best practices of several methods together. -
Seedbank
Seedbank gives your seed data a little structure. Create seeds for each environment, share seeds between environments and specify dependencies to load your seeds in order. All nicely integrated with simple rake tasks. -
DatabaseConsistency
The tool to avoid various issues due to inconsistencies and inefficiencies between a database schema and application models. -
Polo
Polo travels through your database and creates sample snapshots so you can work with real world data in development. -
SchemaPlus
DISCONTINUED. SchemaPlus provides a collection of enhancements and extensions to ActiveRecord -
Upsert
Upsert on MySQL, PostgreSQL, and SQLite3. Transparently creates functions (UDF) for MySQL and PostgreSQL; on SQLite3, uses INSERT OR IGNORE. -
OnlineMigrations
Catch unsafe PostgreSQL migrations in development and run them easier in production (code helpers for table/column renaming, changing column type, adding columns with default, background migrations, etc). -
Ruby PG Extras
Ruby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more. -
Slack Smart Bot
Create a Slack bot that is smart and so easy to expand, create new bots on demand, run ruby code on chat, create shortcuts... The main scope of this gem is to be used internally in the company so teams can create team channels with their own bot to help them on their daily work, almost everything is suitable to be automated!! slack-smart-bot can create bots on demand, create shortcuts, run ruby code... just on a chat channel. You can access it just from your mobile phone if you want and run those tests you forgot to run, get the results, restart a server... no limits. -
PgDriveBackup
Simple solution to make encrypted with ccrypt PostgreSQL backups and storing on Google Drive API -
Perfect Shape
Perfect Shape is a collection of geometric algorithms that are mostly useful for GUI manipulation like checking containment of a point in popular geometric shapes such as rectangle, square, arc, circle, polygon, and paths containing lines, quadratic bézier curves, and cubic bezier curves. Also, some general math algorithms like IEEE-754 Remainder. -
ActiveRecord Setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll). -
Rapidity
Simple but fast Redis-backed distributed rate limiter. Allows you to specify time interval and count within to limit distributed operations. -
PRY-BYETYPO 👋
A Pry plugin that captures exceptions that may arise from typos and deduces the correct command.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Seed dump or a related project?
README
Seed Dump
Seed Dump is a Rails 4 and 5 plugin that adds a rake task named db:seed:dump
.
It allows you to create seed data files from the existing data in your database.
You can also use Seed Dump from the Rails console. See below for usage examples.
Note: if you want to use Seed Dump with Rails 3 or earlier, use version 0.5.3.
Installation
Add it to your Gemfile with:
gem 'seed_dump'
Or install it by hand:
$ gem install seed_dump
Examples
Rake task
Dump all data directly to db/seeds.rb
:
$ rake db:seed:dump
Result:
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" }
])
User.create!([
{ password: "123456", username: "test_1" },
{ password: "234567", username: "test_2" }
])
Dump only data from the users table and dump a maximum of 1 record:
$ rake db:seed:dump MODELS=User LIMIT=1
Result:
User.create!([
{ password: "123456", username: "test_1" }
])
Append to db/seeds.rb
instead of overwriting it:
rake db:seed:dump APPEND=true
Use another output file instead of db/seeds.rb
:
rake db:seed:dump FILE=db/seeds/users.rb
Exclude name
and age
from the dump:
rake db:seed:dump EXCLUDE=name,age
There are more options that can be set— see below for all of them.
Console
Output a dump of all User records:
irb(main):001:0> puts SeedDump.dump(User)
User.create!([
{ password: "123456", username: "test_1" },
{ password: "234567", username: "test_2" }
])
Write the dump to a file:
irb(main):002:0> SeedDump.dump(User, file: 'db/seeds.rb')
Append the dump to a file:
irb(main):003:0> SeedDump.dump(User, file: 'db/seeds.rb', append: true)
Exclude name
and age
from the dump:
irb(main):004:0> SeedDump.dump(User, exclude: [:name, :age])
Options are specified as a Hash for the second argument.
In the console, any relation of ActiveRecord rows can be dumped (not individual objects though)
irb(main):001:0> puts SeedDump.dump(User.where(is_admin: false))
User.create!([
{ password: "123456", username: "test_1", is_admin: false },
{ password: "234567", username: "test_2", is_admin: false }
])
Options
Options are common to both the Rake task and the console, except where noted.
append
: If set to true
, append the data to the file instead of overwriting it. Default: false
.
batch_size
: Controls the number of records that are written to file at a given time. Default: 1000. If you're running out of memory when dumping, try decreasing this. If things are dumping too slow, trying increasing this.
exclude
: Attributes to be excluded from the dump. Pass a comma-separated list to the Rake task (i.e. name,age
) and an array on the console (i.e. [:name, :age]
). Default: [:id, :created_at, :updated_at]
.
file
: Write to the specified output file. The Rake task default is db/seeds.rb
. The console returns the dump as a string by default.
import
: If true
, output will be in the format needed by the activerecord-import gem, rather than the default format. Default: false
.
limit
: Dump no more than this amount of data. Default: no limit. Rake task only. In the console just pass in an ActiveRecord::Relation with the appropriate limit (e.g. SeedDump.dump(User.limit(5))
).
conditions
: Dump only specific records. In the console just pass in an ActiveRecord::Relation with the appropriate conditions (e.g. SeedDump.dump(User.where(state: :active))
).
model[s]
: Restrict the dump to the specified comma-separated list of models. Default: all models. If you are using a Rails engine you can dump a specific model by passing "EngineName::ModelName". Rake task only. Example: rake db:seed:dump MODELS="User, Position, Function"
models_exclude
: Exclude the specified comma-separated list of models from the dump. Default: no models excluded. Rake task only. Example: rake db:seed:dump MODELS_EXCLUDE="User"