database_consistency gem
Add it to your Gemfile:
Gemfile:
group :development do
  gem 'database_consistency',  require: false
end
Some scripts for convenience:
package.json:
  "scripts": {
    "test:consistency": "bundle exec database_consistency",
  }
And run
bundle install
yarn test:consistency
🖖