{"id":24333617,"url":"https://github.com/graysonchen/retry_on_duplicate","last_synced_at":"2025-09-07T08:43:07.613Z","repository":{"id":37923852,"uuid":"383211398","full_name":"graysonchen/retry_on_duplicate","owner":"graysonchen","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-14T14:02:49.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T03:17:55.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/graysonchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-07-05T17:04:05.000Z","updated_at":"2022-06-14T12:14:13.000Z","dependencies_parsed_at":"2022-08-24T17:03:57.276Z","dependency_job_id":null,"html_url":"https://github.com/graysonchen/retry_on_duplicate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graysonchen%2Fretry_on_duplicate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graysonchen%2Fretry_on_duplicate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graysonchen%2Fretry_on_duplicate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graysonchen%2Fretry_on_duplicate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graysonchen","download_url":"https://codeload.github.com/graysonchen/retry_on_duplicate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243048108,"owners_count":20227592,"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":"2025-01-18T03:18:05.142Z","updated_at":"2025-03-11T13:48:20.676Z","avatar_url":"https://github.com/graysonchen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RetryOnDuplicate\n\n[![CircleCI](https://circleci.com/gh/graysonchen/retry_on_duplicate/tree/master.svg?style=svg)](https://circleci.com/gh/graysonchen/retry_on_duplicate)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'retry_on_duplicate'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install retry_on_duplicate\n\n## Usage\n\nadd db:migrate for a unique constraint at the database level \n\n```\nadd_index :users, :email, unique: true\n```\n\nHow to prevent duplicate database record creation\n\n```\nUser.retry_on_duplicate do\n  User.find_or_create_by(email: email)\nend\n```\n\n\n## Problems Solved\n\n- `ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry`\n\n- `ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint `\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/graysonchen/retry_on_duplicate.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraysonchen%2Fretry_on_duplicate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraysonchen%2Fretry_on_duplicate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraysonchen%2Fretry_on_duplicate/lists"}