{"id":13462903,"url":"https://github.com/jenseng/immigrant","last_synced_at":"2025-05-15T10:03:32.423Z","repository":{"id":2887931,"uuid":"3895037","full_name":"jenseng/immigrant","owner":"jenseng","description":"Foreign key migration generator for Rails","archived":false,"fork":false,"pushed_at":"2024-05-08T01:04:14.000Z","size":79,"stargazers_count":485,"open_issues_count":6,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-14T16:53:53.199Z","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/jenseng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-01T19:59:42.000Z","updated_at":"2024-07-19T21:28:45.000Z","dependencies_parsed_at":"2024-06-18T17:13:07.440Z","dependency_job_id":null,"html_url":"https://github.com/jenseng/immigrant","commit_stats":{"total_commits":80,"total_committers":9,"mean_commits":8.88888888888889,"dds":"0.21250000000000002","last_synced_commit":"7678630d2efadd6727dbf642ebc19b2fe45a43da"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenseng%2Fimmigrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenseng%2Fimmigrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenseng%2Fimmigrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenseng%2Fimmigrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenseng","download_url":"https://codeload.github.com/jenseng/immigrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"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-31T13:00:40.680Z","updated_at":"2025-05-15T10:03:29.934Z","avatar_url":"https://github.com/jenseng.png","language":"Ruby","readme":"# Immigrant\n[\u003cimg src=\"https://secure.travis-ci.org/jenseng/immigrant.svg?rvm=1.9.3\" /\u003e](http://travis-ci.org/jenseng/immigrant)\n\nImmigrant gives Rails a foreign key migration generator so you can\neffortlessly find and add missing keys. This is particularly helpful\nwhen you decide to add keys to an established Rails app.\n\n## Installation\n\nAdd the following to your Gemfile:\n\n```ruby\ngem 'immigrant'\n```\n\nIf you're using a version of Rails prior to 4.2, you'll also need the\n[Foreigner](https://github.com/matthuhiggins/foreigner) gem.\n\n## Usage\n\n```bash\nrails generate immigration AddKeys\n```\n\nThis will create a migration named AddKeys which will have `add_foreign_key`\nstatements for any missing foreign keys. Immigrant infers missing ones by\nevaluating the associations in your models (e.g. `belongs_to`, `has_many`, etc.).\nOnly missing keys will be added; existing ones will never be altered or\nremoved.\n\n### Rake Task\n\nTo help you remember to add keys in the future, there's a handy rake\ntask you can add to your CI setup.  Just run `rake immigrant:check_keys`,\nand if anything is missing it will tell you about it and exit with a\nnon-zero status.\n\n### Skipping associations\n\n`Immigrant.ignore_keys` allows you to specify a list of keys that should\nbe ignored (both in the migration generator and the rake task). This is\nuseful if you have associations spanning databases.\n\nJust create an config/initializers/immigrant.rb file with something like\nthe following:\n\n```ruby\nImmigrant.ignore_keys = [\n  { from_table: \"users\", column: \"account_id\" },\n  # etc\n]\n```\n\n## Considerations\n\nIf the data in your tables is bad, then the migration will fail to run\n(obviously). IOW, ensure you don't have orphaned records **before** you try to\nadd foreign keys.\n\n## Known Issues\n\nImmigrant currently only looks for foreign keys in `ActiveRecord::Base`'s\ndatabase. So if a model is using a different database connection and it has\nforeign keys, Immigrant will incorrectly include them again in the generated\nmigration. `Immigrant.ignore_keys` can be used to work around this.\n\n## [Changelog](CHANGELOG.md)\n\n## License\n\nCopyright (c) 2012-2015 Jon Jensen, released under the MIT license\n","funding_links":[],"categories":["Active Record Plugins","Ruby"],"sub_categories":["Active Record Index Assistants"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenseng%2Fimmigrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenseng%2Fimmigrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenseng%2Fimmigrant/lists"}