active_record_doctor
Active Record Doctor is a Ruby gem that automatically detects database design issues in Rails applications—such as missing indexes, foreign key constraints, and schema mismatches—before they reach production. It runs as a Rake task and can be integrated into CI/CD pipelines to enforce database best practices.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | gregnavis/active_record_doctor |
| Owner | gregnavis |
| Primary language | Ruby |
| License | MIT — OSI-approved |
| Stars | 1.9k |
| Forks | 70 |
| Open issues | 33 |
| Latest release | Unknown |
| Last updated | 2026-01-12 |
| Source | https://github.com/gregnavis/active_record_doctor |
What active_record_doctor is
A linting tool for Active Record models and database schemas that inspects Rails migrations, model validations, and database constraints to identify 15+ categories of issues including extraneous indexes, missing foreign keys, type mismatches, and schema inconsistencies. Supports MySQL and PostgreSQL via CI workflows and integrates via Rake or Rails commands.
Get the active_record_doctor source
Clone the repository and explore it locally.
git clone https://github.com/gregnavis/active_record_doctor.gitcd active_record_doctor# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Gem should be installed in development and test groups only; ensure Gemfile clearly isolates it to avoid production bloat.
- Requires Active Record models to be preloaded and database connection established before running—non-Rails projects need explicit Rake setup with `task.setup` Proc.
- Review and commit `.active_record_doctor.rb` configuration to version control so all team members and CI environments use consistent ignore rules.
- For large codebases, start with specific detectors (e.g., `rake active_record_doctor:missing_foreign_keys`) rather than running all checks at once to manage output.
- Test detector output against both development and staging database schemas if they differ; PostgreSQL and MySQL have different constraint and index capabilities.
When to avoid it — and what to weigh
- Non-Rails or Non-Active Record Stack — This tool is tightly coupled to Active Record and Rails conventions. If you use Sequel, DataMapper, or ORMs outside Ruby, you will need alternative linting approaches.
- Unconventional Schema Patterns — If your schema intentionally deviates from Rails norms (e.g., composite primary keys, no timestamps on specific tables, intentional denormalization), the tool's opinionated checks may generate false positives requiring extensive ignore configuration.
- Frequent Dynamic Schema Changes — For applications that heavily modify schemas programmatically or use features like multi-tenancy with dynamic table generation, the static analysis approach may miss or misreport issues.
- Zero Configuration Tolerance — Out-of-the-box detection targets Rails best practices and requires a `.active_record_doctor.rb` config file for realistic use; teams needing zero upfront tuning may find setup friction.
License & commercial use
Licensed under MIT (MIT License), a permissive OSI-approved license. Permits commercial use, modification, and distribution with minimal restrictions; requires only attribution and inclusion of license text in copies.
MIT license clearly permits commercial use. No license restrictions prevent bundling into production-deployed gems or closed-source Rails applications. However, ensure compliance with any upstream Active Record gem licenses if extended or redistributed.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Tool performs static analysis only—reads schema and model definitions, does not execute data access or modification. Requires database read access (connection string in environment). Ensure CI environments and development machines do not expose production credentials when running the tool. No known security vulnerabilities reported in GitHub issues; typical gems hygiene applies (audit dependencies).
Alternatives to consider
Riddle (schema linting gem)
Alternative schema linter for Rails with overlapping checks (missing indexes, foreign keys). Less actively maintained and narrower scope; Active Record Doctor covers more issues and has stronger CI integration.
Manual code review + ERD generation (rails-erd)
Graphical schema visualization with manual auditing. No automation; suitable for teams with strong DBA discipline but does not integrate into CI or catch issues at commit time.
Database-native constraint/audit tools (pg_stat_statements for PostgreSQL, MySQL slow log)
Database-level performance and constraint monitoring. Catches runtime issues but requires production instrumentation and does not analyze model-schema alignment; complements rather than replaces Active Record Doctor.
Build on active_record_doctor with DEV.co software developers
Integrate Active Record Doctor into your CI/CD pipeline to catch schema problems, missing indexes, and constraint mismatches automatically. Start with the free, MIT-licensed gem today.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
active_record_doctor FAQ
Does Active Record Doctor modify the database or migrations?
Can I run it against production?
How does it handle Rails engines or multitenancy?
What Rails versions are supported?
Software development & web development with DEV.co
Adopting active_record_doctor is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.
Prevent Database Issues in Your Rails App
Integrate Active Record Doctor into your CI/CD pipeline to catch schema problems, missing indexes, and constraint mismatches automatically. Start with the free, MIT-licensed gem today.