{"id":23486885,"url":"https://github.com/dsalahutdinov/activerecord-data_integrity","last_synced_at":"2025-09-16T03:45:35.180Z","repository":{"id":43866850,"uuid":"153391169","full_name":"dsalahutdinov/activerecord-data_integrity","owner":"dsalahutdinov","description":"Check data integrity for your ActiveRecord models","archived":false,"fork":false,"pushed_at":"2022-07-19T13:28:43.000Z","size":94,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T11:20:46.402Z","etag":null,"topics":["activerecord","activerecord-models","consistency","constraints","dataintegrity","foreign-keys","notnull","rails","ruby"],"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/dsalahutdinov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-17T03:38:20.000Z","updated_at":"2025-07-07T15:39:49.000Z","dependencies_parsed_at":"2022-07-09T06:30:59.100Z","dependency_job_id":null,"html_url":"https://github.com/dsalahutdinov/activerecord-data_integrity","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dsalahutdinov/activerecord-data_integrity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsalahutdinov%2Factiverecord-data_integrity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsalahutdinov%2Factiverecord-data_integrity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsalahutdinov%2Factiverecord-data_integrity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsalahutdinov%2Factiverecord-data_integrity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsalahutdinov","download_url":"https://codeload.github.com/dsalahutdinov/activerecord-data_integrity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsalahutdinov%2Factiverecord-data_integrity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275358671,"owners_count":25450443,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["activerecord","activerecord-models","consistency","constraints","dataintegrity","foreign-keys","notnull","rails","ruby"],"created_at":"2024-12-24T22:17:38.603Z","updated_at":"2025-09-16T03:45:35.115Z","avatar_url":"https://github.com/dsalahutdinov.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/activerecord-data_integrity.svg)](https://badge.fury.io/rb/activerecord-data_integrity)\n[![Build Status](https://travis-ci.org/dsalahutdinov/activerecord-data_integrity.svg?branch=master)](https://travis-ci.org/dsalahutdinov/activerecord-data_integrity.svg?branch=master)\n\n# ActiveRecord::DataIntegrity\n\nChecks your ActiveRecord models to match data integrity principles and rules.\nOut of the box it detects many issues such as the lack of foreign keys.\n\n## Intallation\n```ruby\ngroup :development do\n  ...\n  gem 'activerecord-data_integrity', require: false\nend\n```\n## Quickstart\n\nRun `data_integrity` CLI-tool in your Rails project's folder:\n\n```bash\ncd ~/amplifr\nbundle exec data_integrity\n```\n\nIt will load the Rails application, check the data integrity issues and give the similar output:\n```\nBelongsTo/ForeignKey: Label belongs_to project but has no foreign key to projects.id\nAccordance/TablePresence: Stat::Hourly has no underlying table hourly_stats\n...\n```\n\n## Options\n\nCheck only specified database rules with `--only` options:\n```\n  bundle exec data_integrity --only HasMany/ForeignKey,BelongsTo/ForeignKey\n```\nCheck only specified model with the list of the model full with:\n```sh\n  bundle exec data_integrity --only HasMany/ForeignKye Billing::Account User\n```\n\n## Supported Issues\n\nFor now tool checks the following issues:\n - [x] The lack of database foreign keys for belongs_to/has_many associations (`HasMany/ForeignKey` and `BelongsTo/ForeignKey` rule)\n - [x] The lack of not-null constraint for the columns with presence validation (`Validation/Presence` rule)\n - [x] Inclusion validated colums should have `enum` data type (`Validation/Inclusion` rule)\n\n## Roadmap (TODO \u0026 Help Wanted)\n\n1) Support extra database issues, such as:\n - [ ] presence of `dependend` option set for association and not confliction with underlying `ON DELETE` option of foreign key contraint\n - [ ] check for foreign keys to have bigint data type\n - [ ] presence of index for the foreign keys search\n - [ ] checks for paranoia models and indexes exclusion \"removed\" rows\n\n2) Config for exluding some rules for the specific models (rubocop like)\n\n3) Autofix for the fixing the issue, mostly by generating safe migrations\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activerecord-data_integrity.\n\n## Run tests\n\nThe easiest way to tests up and running is to use handy [dip](https://github.com/bibendi/dip) gem with Docker and Docker Compose:\n\n```bash\ngem install dip\ngit checkout git@github.com:dsalahutdinov/activerecord-data_integrity.git\ncd activerecord-data_integrity\ndip provision\ndip rspec\n```\n\nOtherwise (without Docker) set up environment manually:\n```bash\ngit checkout git@github.com:dsalahutdinov/activerecord-data_integrity.git\ncd activerecord-data_integrity\nbundle install\nbundle appraisal\nDB_HOST=localhost DB_NAME=testdb DB_USERNAME=postgres bundle appraisal rspec\n```\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%2Fdsalahutdinov%2Factiverecord-data_integrity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsalahutdinov%2Factiverecord-data_integrity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsalahutdinov%2Factiverecord-data_integrity/lists"}