Automating Consistency Checks in Development

Let’s look at some command-line tools provided as Ruby gems that have been added to Rideshare.

Rideshare uses the active_record_doctor[104] gem to analyze the database and the application code.

To run it, go to your terminal and run bin/rake active_record_doctor from the Rideshare directory. This runs the built-in checks and makes recommendations.

One of the checks compares the column types between the primary key and foreign key columns to make sure they match. Some mismatches exist in Rideshare now, so try running the tool and finding them. Feel free to fix them in your local copy.

Validations defined in models are also compared against database constraints. For example, when a uniqueness validation ...

Get High Performance PostgreSQL for Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.