Skip to content
CAI
Software that uses CAICheck a score

djezzzl/database_consistency

47.9

Weak · 6 November 2026

6.3k

lines of production code

Ruby

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add Rails 6 example application with Zeitwerk and Webpacker

Added a new \rails6-example\ directory containing a scaffolded Rails 6 application. This example demonstrates integration with the Zeitwerk code loader and Webpacker for JavaScript asset management, including configuration for Babel, PostCSS, and Webpack. It also includes standard Rails 6 features such as Active Storage, Action Cable, and encrypted credentials, providing a reference implementation for users upgrading to or starting with Rails 6.

rails6-example · high confidence

Add Rails 8 example application

This change introduces a new \rails8-example\ application scaffolded for Rails 8.0, providing a reference implementation for modern Rails development. The example includes a production-ready Dockerfile and Kamal deployment configuration, enabling containerized deployment with Thruster as the HTTP server. It demonstrates Rails 8 features such as \allow\_browser versions: :modern\ for browser compatibility, multi-database support via a \SecondaryRecord\ class, and the adoption of Solid Queue for background jobs and Solid Cable for Action Cable. The setup also integrates Hotwire (Turbo and Stimulus) via Importmaps, uses Propshaft for asset management, and includes sample models and database consistency checks to illustrate best practices.

rails8-example · high confidence

Add enum type consistency checking

The library now includes a new \EnumTypeChecker\ that validates whether the database column type for an enum matches the types of its defined values. This checker ensures that enum values are stored in the database using the correct data type (e.g., string, integer, date), helping users detect and fix inconsistencies between their model definitions and the actual database schema.

_lib/database\_consistency/checkers/enum\checkers · high confidence

Initial Rails 7 example application scaffold

This location introduces a complete Rails 7 example application scaffold, providing the foundational structure for a multi-database setup. It includes configuration for primary and secondary databases (SQLite and PostgreSQL), database consistency checking settings, and standard Rails 7 components such as ActionCable, Hotwire (Turbo/Stimulus), and Puma. The entry also establishes the initial database schema and migrations for core models like Users, Companies, and Countries.

rails7-example · high confidence

Initial Rails example application scaffold

This change introduces a complete, default Rails application structure to the \rails-example\ directory. It includes standard configuration files for the application environment, database (SQLite3), caching (Redis for production), and credentials encryption, alongside the necessary directory scaffolding for controllers, models, views, assets, and channels. The diff also adds database migrations for \users\, \countries\, and \companies\ tables, a schema definition, and a \database\_consistency.yml\ configuration file to enable database integrity checks.

rails-example · high confidence

Introduce \`database\_consistency\` CLI with install, autofix, and config options

The \bin/database\_consistency\ executable is now the primary entry point for the tool, replacing the previous \bin/console\ and \bin/setup\ scripts. Users can now run \database\_consistency install\ to automatically add default configuration rules to their project. The CLI supports several new options: \--config\ to load additional configuration files, \--generate-todo\ to create a TODO file listing disabled checks, and \--autofix\ to automatically correct issues or generate missing migrations. Additionally, \--only-checkers\ allows users to restrict autofixing to specific checker classes. The tool requires being run from the root directory of a Rails project and supports Rails 6 Zeitwerk.

bin · high confidence

Introduces Simple Writer for database consistency reports

Adds a new Simple Writer implementation in lib/database\_consistency/writers/simple that provides a structured, color-coded output format for database consistency checks. This writer includes a Base class for handling report formatting and a comprehensive set of specific checkers covering association integrity (foreign keys, null constraints, missing indexes), data validation consistency (enum values, length validators, numericality constraints), and schema best practices (view primary keys, implicit order columns, small primary keys). Users will now see detailed, actionable messages when database structures diverge from ActiveRecord expectations, such as missing NOT NULL constraints, redundant indexes, or mismatched foreign key types.

_lib/database\consistency/writers/simple · high confidence

New autofix migration writers for common database inconsistencies

The \lib/database\_consistency/writers/autofix\ directory now includes a set of new classes and ERB templates that automatically generate Rails migrations to fix specific database issues detected by the tool. Specifically, the system can now write migrations to add missing indexes on association columns (\AssociationMissingIndex\), enforce unique constraints on \has\_one\ associations (\HasOneMissingUniqueIndex\), correct inconsistent column types (\InconsistentTypes\), add missing foreign key constraints (\MissingForeignKey\), add \NOT NULL\ constraints (\NullConstraintMissing\), and remove redundant indexes (\RedundantIndex\). These writers provide a base infrastructure (\Base\, \MigrationBase\) to safely generate and write these migration files only if they do not already exist.

_lib/database\consistency/writers/autofix · high confidence

New column consistency checkers for enums, lengths, nulls, and performance

This release introduces a suite of new column-level checkers to enforce database and application consistency. The EnumValueChecker ensures PostgreSQL enum values and ActiveRecord enums or inclusion validators stay aligned. The LengthConstraintChecker validates that string/text columns have database length limits matching their length validators. The NullConstraintChecker detects missing presence, inclusion, exclusion, or numericality validators on non-null columns, including those backed by belongs\_to associations. The ThreeStateBooleanChecker flags boolean columns that lack NOT NULL constraints, preventing unintended three-state logic. The PrimaryKeyTypeChecker recommends migrating small integer/serial primary keys to bigint/bigserial/uuid for scalability. The ImplicitOrderingChecker ensures models with UUID primary keys define implicit\_order\_column. Finally, the MissingIndexFindByChecker uses the Prism AST parser (Ruby 3.3+) to detect find\_by calls on unindexed columns, skipping booleans and primary keys to reduce noise.

_lib/database\_consistency/checkers/column\checkers · high confidence

New example applications for Rails 6, 7, and 8

The repository now includes dedicated example applications for Rails 6, 7, and 8, providing updated templates for testing database consistency. These examples demonstrate modern Rails patterns, including the use of \primary\_abstract\_class\ in Rails 7 and 8, explicit \required: true\ on associations, and multi-database configurations using \connects\_to\ with secondary databases. The examples also cover various validation scenarios, polymorphic associations, and custom validators to help users verify their own setups against these common configurations.

_database\consistency · high confidence

New index consistency checkers for redundancy and uniqueness validation

The \lib/database\_consistency/checkers/index\_checkers\ directory now includes four new checkers that enforce database schema consistency. \RedundantIndexChecker\ detects non-unique B-tree indexes that are fully covered by a prefix of another index on the same table and conditions. \RedundantUniqueIndexChecker\ identifies unique indexes that are redundant because another unique index covers all their columns and conditions. \UniqueIndexChecker\ ensures that every unique database index has a corresponding \validates\_uniqueness\_of\ validator in the Rails model, checking for column match and condition alignment. These changes introduce new behavioral checks for schema hygiene, reporting failures when redundancy or missing validations are detected.

_lib/database\_consistency/checkers/index\checkers · high confidence

New model consistency checkers for missing tables and view primary keys

Added three new checkers to enforce database schema consistency: MissingTableChecker ensures models have corresponding database tables, ViewPrimaryKeyChecker enforces that models backed by database views explicitly define a primary key that exists in the view schema, and ModelChecker serves as the base class for these model-level validations.

_lib/database\_consistency/checkers/model\checkers · high confidence

New validator checkers for uniqueness validation consistency

The tool now includes specific checkers to validate database schema against Rails uniqueness validators. A new \CaseSensitiveUniqueValidationChecker\ detects redundant \case\_sensitive: false\ options on PostgreSQL \citext\ columns, while the \MissingUniqueIndexChecker\ ensures that uniqueness validators are backed by corresponding unique indexes in the database, including support for compound primary keys and conditional index matching.

_lib/database\_consistency/checkers/validator\checkers · high confidence

New validator-to-constraint consistency checkers for presence and numericality

Added two new database consistency checkers that verify Rails model validators have corresponding database-level constraints. The ColumnPresenceChecker ensures that \presence\ validators on regular columns and associations are backed by \NOT NULL\ constraints in the database, including handling polymorphic associations and weak options like \allow\_nil\ or \on\. The NumericalityConstraintChecker ensures that \numericality\ validators with range options (e.g., \greater\_than\, \in\) have corresponding \CHECK\ constraints in the database, while skipping validators that only assert 'is a number' (which is already guaranteed by the column type). These checkers are part of the ValidatorsFractionChecker framework, which processes model validators and compares them against the actual database schema.

_lib/database\_consistency/checkers/validators\_fraction\checkers · high confidence

Architecture

Refactored database consistency checks into a modular processor architecture

The database consistency checking logic has been restructured from a monolithic implementation into a modular system of dedicated processors. New files in \lib/database\_consistency/processors\ introduce specific handlers for models, columns, associations, indexes, enums, and validators, all inheriting from a new \BaseProcessor\. This change centralizes the execution flow, allowing the system to automatically discover and run enabled checkers against the appropriate model components (such as iterating through associations or validator attributes) while maintaining consistent error handling and debugging context.

_lib/database\consistency/processors · high confidence

Behavioural changes

Autofix migration helper ensures valid timestamp versions and context compatibility

The new \lib/database\_consistency/writers/autofix/helpers/migration.rb\ helper ensures that autofix-generated migrations maintain valid timestamp-based version numbers by incrementing the previous migration's timestamp by one second, preventing duplication errors. It also adapts to different ActiveRecord versions by checking the \MigrationContext\ initializer arity and using the connection pool's schema migration when available, ensuring the autofix process works correctly across various database consistency contexts.

_lib/database\consistency/writers/autofix/helpers · high confidence

Automatic checker registration via inheritance

Checkers are now automatically registered with the system when they inherit from the BaseChecker class, removing the need for manual registration steps. This simplifies the process of adding new consistency checks, as the framework detects and includes any new checker subclass automatically upon definition.

_lib/database\consistency/checkers · high confidence

Database Consistency tool upgraded to version 3.0.14

The database\_consistency library has been updated to version 3.0.14. This release introduces a new configuration system that supports loading multiple YAML configuration files, using YAML aliases, and loading custom checkers via a 'require' directive. It also adds support for the LOG\_LEVEL environment variable and colored output. The tool now uses the Prism AST parser to detect find\_by usage on unindexed columns and includes a new DebugContext for better debugging. Several legacy comparators and result formatting modules have been removed in favor of a new ReportBuilder structure.

_lib/database\consistency · high confidence

Expand CI test matrix to Ruby 2.6–4.0 and ActiveRecord 4.2–8.1

The project's continuous integration now tests against a significantly broader range of environments, adding support for ActiveRecord 7.2, 8.0, and 8.1, as well as Ruby 3.3, 3.4, and 4.0. This is achieved by introducing an \Appraisals\ file that pins compatible versions of \rubocop\ (legacy 1.50.x for Ruby 2.6, current 1.75.x for Ruby 2.7+) and database adapters (e.g., \sqlite3\ \>= 2.0 for newer Rails versions) for each appraisal, replacing the previous Travis CI configuration.

(repo-wide) · high confidence

Major architectural refactor introducing modular checkers, processors, and writers

The library has been restructured from a monolithic design into a modular architecture. The main entry point now instantiates a Configuration object and delegates analysis to a suite of dedicated Processors (for models, associations, columns, validators, indexes, and enums). Results are handled by a new Writer system, which replaces the previous comparison logic with specialized writers for simple reporting, TODO generation, and autofixing. This change introduces a comprehensive set of new checkers (e.g., for foreign key cascades, enum consistency, missing indexes, and view primary keys) and their corresponding autofix capabilities, significantly expanding the tool's detection and remediation scope.

lib · high confidence

New association consistency checkers for foreign keys, indexes, and nullability

The association checking subsystem has been expanded with several new validators to enforce database schema integrity. A new base \AssociationChecker\ class centralizes logic for these checks. Specific new checkers include \ForeignKeyCascadeChecker\ to ensure foreign key cascade options match the Rails \dependent\ option, \ForeignKeyTypeChecker\ to verify that foreign key column types are large enough to cover the associated primary key, and \PolymorphicAssociationNullabilityChecker\ to ensure the foreign key and type columns in polymorphic associations share the same nullability constraint. Additionally, \MissingIndexChecker\ now distinguishes between standard and unique indexes for \has\_one\ associations, while \MissingDependentDestroyChecker\ and \MissingAssociationClassChecker\ provide stricter validation for dependent destroy setups and valid association class references respectively.

_lib/database\_consistency/checkers/association\checkers · high confidence

New writer subsystem for output, autofix, and TODO generation

The tool now uses a new \Writers\ module to handle report output and remediation. Users can generate a YAML TODO file via \TodoWriter\ to track issues, apply automatic fixes for supported database inconsistencies via \AutofixWriter\ (which maps error slugs to specific generator classes), or view simple console messages via \SimpleWriter\. This replaces the previous formatting logic with a structured, extensible writer architecture.

_lib/database\consistency/writers · high confidence

Fixes

Add SQLite type mapping for foreign key consistency checks

Introduces a new SQLite type handler that maps database-specific integer types (such as 'bigserial', 'serial', and sized integers) to their standard SQL equivalents (bigint, integer, smallint). This ensures that foreign key type consistency checks correctly identify compatible column types in SQLite databases, preventing false positives during schema validation.

_lib/database\consistency/databases · high confidence

Test coverage

Added PostgreSQL-specific tests for EnumTypeChecker; Added test coverage for ForeignKeyTypeChecker on PostgreSQL and SQLite; Added test coverage for RedundantIndexChecker across MySQL, PostgreSQL, and SQLite; Added test coverage for autofix migration writers; Added test coverage for new and existing database consistency checkers; Added tests for BaseProcessor error handling; Added tests for PostgreSQL length constraint and unique index checkers; Added tests for RedundantUniqueIndexChecker across MySQL, PostgreSQL, and SQLite; Added tests for SQL clause parsing and parenthesis helper modules; Added tests for UniqueIndexChecker partial index support; Migrate specs to multi-database support and add new test coverage.

Dependencies

Add Rails 6, 7, and 8 example apps and update gem dependencies

This change introduces new example applications for Rails 6, 7, and 8, allowing users to see how the \database\_consistency\ gem integrates with modern Rails versions. The core gem's dependencies have been updated to support these versions, with \activerecord\ now required as a runtime dependency (\>= 3.2) and development dependencies for \mysql2\, \pg\, and \sqlite3\ added to facilitate testing across different database adapters. Additionally, the minimum supported Ruby version has been raised to 2.6.0, and a post-install message with funding information has been added to the gemspec.

(dependencies) · high confidence

Expanded ActiveRecord version support in CI gemfiles

The CI gemfiles have been updated to include test configurations for ActiveRecord versions 7.1, 7.2, 8.0, and 8.1, alongside the existing 4.2, 5.2, 6.0, 6.1, and 7.0 setups. Additionally, the gemfiles for ActiveRecord 7.2 and newer now require sqlite3 version 2.0 or higher, while the main branch configuration points to the Rails repository's main branch.

gemfiles · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 48 → 48 (+0.1)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 35 → 35 (+0.0)
  • Architecture 93 → 93 (+0.0)
  • Maturity 57 → 61 (+4.1)
  • Readiness 54 → 54 (+0.2)
  • Security 68 → 62 (-6.4)
  • Domain Modelling 100 → 100 (+0.0)
  • Accessibility 54 → 54 (+0.0)

Resolved (5)

  • Outdated: jbuilder
  • Outdated: selenium-webdriver
  • Outdated: spring
  • Outdated: turbo-rails
  • Outdated: web-console

New (1)

  • Off-boarding risk: anonymized user #1

Changes since last survey

  • 25 commits — 18 feature/other, 7 fixes

By area

  • (root) — 11 commits
  • (repo) — 10 commits
  • lib/database_consistency — 4 commits

Notable commits

  • fix: Fix project_klass? method for both cases
  • fix: Fix the ForeignKeyCascadeChecker message
  • fix: Fix the empty ForeignKeyTypeChecker message
  • fix: Merge branch 'master' into fix-cascade-option-message
  • fix: Merge pull request #327 from manuelmeurer/fix-inconsistent-types-message
  • fix: Merge pull request #328 from manuelmeurer/fix-cascade-option-message
  • fix: Merge pull request #331 from paul/fix-symlinked-bundle-path
  • change: Apply remaining changes
  • change: Apply suggestion from @djezzzl
  • change: Count the primary key as an index in the missing index check
  • change: Merge branch 'master' into consider-primary-key-in-missing-index-check
  • change: Merge branch 'master' into skip-missing-index-check-without-table
  • change: Merge pull request #329 from manuelmeurer/skip-missing-index-check-without-table
  • change: Merge pull request #330 from manuelmeurer/consider-primary-key-in-missing-index-check
  • change: Merge pull request #332 from djezzzl/copilot/add-changelog-entry
  • change: Merge pull request #333 from garrettblehm/postgis-adapter
  • change: Refactor Bundler path checks for clarity
  • change: Release v3.1.1
  • change: Release v3.1.2
  • change: Resolve symlinks in the bundle path when finding project models
  • …and 5 more

Architecture

  • Unchanged — 0 containers · 1 contexts · 0 edges

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

djezzzl/database_consistency was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 622356c9b31962b7ea4dbcb6b058784c1179b90a — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.