{"id":25619329,"url":"https://github.com/hunterae/dumpable","last_synced_at":"2026-02-27T17:37:22.220Z","repository":{"id":8890684,"uuid":"10610283","full_name":"hunterae/dumpable","owner":"hunterae","description":"Let Rails dump out your SQL","archived":false,"fork":false,"pushed_at":"2020-03-11T04:03:50.000Z","size":25,"stargazers_count":11,"open_issues_count":2,"forks_count":16,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-06T19:15:36.381Z","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/hunterae.png","metadata":{"files":{"readme":"README.rdoc","changelog":"CHANGELOG.rdoc","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-10T21:50:50.000Z","updated_at":"2024-01-31T10:28:01.000Z","dependencies_parsed_at":"2022-08-24T12:50:57.220Z","dependency_job_id":null,"html_url":"https://github.com/hunterae/dumpable","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/hunterae/dumpable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fdumpable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fdumpable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fdumpable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fdumpable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hunterae","download_url":"https://codeload.github.com/hunterae/dumpable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fdumpable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29906437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T17:28:36.873Z","status":"ssl_error","status_checked_at":"2026-02-27T17:28:20.970Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-02-22T06:16:56.765Z","updated_at":"2026-02-27T17:37:22.198Z","avatar_url":"https://github.com/hunterae.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= dumpable\n\nThe situation is all too common. There is an error in production that you want to reproduce in your local\ndevelopment environment. Only problem is that the production environment has database data that you don't have locally. \n\nSo then you generally only have one option: dump your entire production database, or a subset of your production\ndatabase to a sql file and import the dump into your local database.\n\nWhat if time is of the essense, and the production database is huge? What if you could dump only the\nspecific records and their associations that you need to reproduce the record causing problems in your local database. \n\nDumpable allows you to do just that. You can dump single rows (or a collection of rows), \nand choose which associations to dump with those rows.\n\n== Installation\nAdd the following to your Gemfile:\n  gem 'dumpable'\n\n== Usage\nThe dumpable gem will automatically add the class method #dumpable and the instance method #dump into all your \nActiveRecord models.\n\nBy default, calling dump on any record will output the sql insert statement necessary to create that record.\nIt will not generate the insert statements for any of the record's associations. These can either be specified\nclass level by calling #dumpable with the set of assocations to dump or a run-time in your call to #dump.\n\nBoth cases will be demonstrated below.\n\n  class User \u003c ActiveRecord::Base\n    has_many :posts\n    has_many :roles\n\n    dumpable dumps: [:roles, {:posts =\u003e :comments}]\n  end\n\n  class Role \u003c ActiveRecord::Base\n    belongs_to :user\n  end\n\n  class Post \u003c ActiveRecord::Base\n    has_many :comments\n  end\n\n  class Comments \u003c ActiveRecord::Base\n    belongs_to :post\n  end\n\nThen, from the console, you can do something like:\n  User.first.dump\nThis will spit out all the MySQL insertion code for the user, it's roles, it's posts, and each post's comments\n\nIf you want each record to pad the ids generated in the insertion code, this can be done as follows:\n  User.first.dump(:id_padding =\u003e 1000)\nThis will ensure that the id of the above user is padded by 1000, so a user id of 1 will generate an insert statement with an id of 1001.\n\nYou may wonder why the id is included as part of the insert statement. This is to ensure that all associations maintain their relationship to one another.\n\nAll ActiveRecord models are dumpable automatically, so you could also call:\n  Post.dump\n  # or\n  Post.dump(:dumps =\u003e :comments)\n\nYou can also dump all the entries in the table by calling:\n  Post.dump\n  # or with conditions\n  Post.where(:published =\u003e true).dump\n\n== Dumping to a sql file\n  User.dump(:file =\u003e PATH_TO_FILE)\n\n== Dumping multiple different record types\n  Dumpable.dump(Post, Comment.limit(10), Role.where(:active =\u003e true)) # will output to console\n  Dumpable.dump(Post, Comment.limit(10), Role.where(:active =\u003e true), :file =\u003e \"dump.sql\") # will output to file\n\n== Gotchas\nAt the moment, Dumpable will not work on any complex relationships. This includes has_many :through, and has_and_belongs_to_many.\nIt also will not work on models that have a different primary key than id or on models with complex keys.\n\nIt is also only setup to work with MySQL databases and is untested with any other databases.\n\n== Copyright\n\nCopyright (c) 2013 Andrew Hunter. See LICENSE.txt for\nfurther details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunterae%2Fdumpable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhunterae%2Fdumpable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunterae%2Fdumpable/lists"}