{"id":13395048,"url":"https://github.com/rroblak/seed_dump","last_synced_at":"2025-04-10T23:20:39.301Z","repository":{"id":992332,"uuid":"800495","full_name":"rroblak/seed_dump","owner":"rroblak","description":"Rails 4/5 task to dump your data to db/seeds.rb","archived":false,"fork":false,"pushed_at":"2023-10-16T23:31:32.000Z","size":231,"stargazers_count":1388,"open_issues_count":52,"forks_count":225,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-10-29T15:27:35.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rroblak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2010-07-27T12:31:39.000Z","updated_at":"2024-10-23T06:23:49.000Z","dependencies_parsed_at":"2024-01-08T17:13:05.109Z","dependency_job_id":"553820a6-339d-4133-84f6-cfdf0b3dbefd","html_url":"https://github.com/rroblak/seed_dump","commit_stats":{"total_commits":246,"total_committers":27,"mean_commits":9.11111111111111,"dds":0.5691056910569106,"last_synced_commit":"7d599d3c5be2d8b2662df9a93be2faa9415294f3"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroblak%2Fseed_dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroblak%2Fseed_dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroblak%2Fseed_dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rroblak%2Fseed_dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rroblak","download_url":"https://codeload.github.com/rroblak/seed_dump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312800,"owners_count":21082759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:40.377Z","updated_at":"2025-04-10T23:20:39.269Z","avatar_url":"https://github.com/rroblak.png","language":"Ruby","readme":"Seed Dump\n========\n\nSeed Dump is a Rails 4 and 5 plugin that adds a rake task named `db:seed:dump`.\n\nIt allows you to create seed data files from the existing data in your database.\n\nYou can also use Seed Dump from the Rails console. See below for usage examples.\n\nNote: if you want to use Seed Dump with Rails 3 or earlier, use [version 0.5.3](http://rubygems.org/gems/seed_dump/versions/0.5.3).\n\nInstallation\n------------\n\nAdd it to your Gemfile with:\n```ruby\ngem 'seed_dump'\n```\nOr install it by hand:\n```sh\n$ gem install seed_dump\n```\nExamples\n--------\n\n### Rake task\n\nDump all data directly to `db/seeds.rb`:\n```sh\n  $ rake db:seed:dump\n```\nResult:\n```ruby\nProduct.create!([\n  { category_id: 1, description: \"Long Sleeve Shirt\", name: \"Long Sleeve Shirt\" },\n  { category_id: 3, description: \"Plain White Tee Shirt\", name: \"Plain T-Shirt\" }\n])\nUser.create!([\n  { password: \"123456\", username: \"test_1\" },\n  { password: \"234567\", username: \"test_2\" }\n])\n```\n\nDump only data from the users table and dump a maximum of 1 record:\n```sh\n$ rake db:seed:dump MODELS=User LIMIT=1\n```\n\nResult:\n```ruby\nUser.create!([\n  { password: \"123456\", username: \"test_1\" }\n])\n```\n\nAppend to `db/seeds.rb` instead of overwriting it:\n```sh\nrake db:seed:dump APPEND=true\n```\n\nUse another output file instead of `db/seeds.rb`:\n```sh\nrake db:seed:dump FILE=db/seeds/users.rb\n```\n\nExclude `name` and `age` from the dump:\n```sh\nrake db:seed:dump EXCLUDE=name,age\n```\n\nThere are more options that can be set— see below for all of them.\n\n### Console\n\nOutput a dump of all User records:\n```ruby\nirb(main):001:0\u003e puts SeedDump.dump(User)\nUser.create!([\n  { password: \"123456\", username: \"test_1\" },\n  { password: \"234567\", username: \"test_2\" }\n])\n```\n\nWrite the dump to a file:\n```ruby\nirb(main):002:0\u003e SeedDump.dump(User, file: 'db/seeds.rb')\n```\n\nAppend the dump to a file:\n```ruby\nirb(main):003:0\u003e SeedDump.dump(User, file: 'db/seeds.rb', append: true)\n```\n\nExclude `name` and `age` from the dump:\n```ruby\nirb(main):004:0\u003e SeedDump.dump(User, exclude: [:name, :age])\n```\n\nOptions are specified as a Hash for the second argument.\n\nIn the console, any relation of ActiveRecord rows can be dumped (not individual objects though)\n```ruby\nirb(main):001:0\u003e puts SeedDump.dump(User.where(is_admin: false))\nUser.create!([\n  { password: \"123456\", username: \"test_1\", is_admin: false },\n  { password: \"234567\", username: \"test_2\", is_admin: false }\n])\n```\n\nOptions\n-------\n\nOptions are common to both the Rake task and the console, except where noted.\n\n`append`: If set to `true`, append the data to the file instead of overwriting it. Default: `false`.\n\n`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.\n\n`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]`.\n\n`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.\n\n`import`: If `true`, output will be in the format needed by the [activerecord-import](https://github.com/zdennis/activerecord-import) gem, rather than the default format. Default: `false`.\n\n`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))`).\n\n`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))`).\n\n`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\"`\n\n`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\"`\n","funding_links":[],"categories":["Ruby","Database Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frroblak%2Fseed_dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frroblak%2Fseed_dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frroblak%2Fseed_dump/lists"}