# Activerecord::PedantMysql2 [![Build Status](https://secure.travis-ci.org/Shopify/activerecord-pedantmysql2-adapter.png)](http://travis-ci.org/Shopify/activerecord-pedantmysql2-adapter) [![Code Climate](https://codeclimate.com/github/Shopify/activerecord-pedantmysql2-adapter.png)](https://codeclimate.com/github/Shopify/activerecord-pedantmysql2-adapter) [![Coverage Status](https://coveralls.io/repos/Shopify/activerecord-pedantmysql2-adapter/badge.png)](https://coveralls.io/r/Shopify/activerecord-pedantmysql2-adapter) [![Gem Version](https://badge.fury.io/rb/activerecord-pedantmysql2-adapter.png)](http://badge.fury.io/rb/activerecord-pedantmysql2-adapter) ActiveRecord adapter for MySQL that report warnings. The main usage is to progressively identify and fix MySQL warnings generated by legacy rails applications, and ultimately enable strict mode. Alternatively it can be used to treat all MySQL warnings as errors. ## Installation Add this line to your application's Gemfile: gem 'activerecord-pedantmysql2-adapter' And then execute: $ bundle Finally in your `database.yml`: adapter: pedant_mysql2 ## Usage By default it do nothing with the warnings, you have to define the behaviour yourself in an initializer. You can either raise on all errors: ```ruby PedantMysql2.on_warning = lambda { |warning| raise warning } ``` Or report them to your exception tracker: ```ruby PedantMysql2.on_warning = lambda { |warning| Airbrake.notify(warning) } ``` Or whatever else behaviour you want (logging). You can easilly whitelist some types of warnings: ```ruby PedantMysql2.on_warning = lambda do |warning| raise warning unless WARNINGS_WHITELIST.any? { |pattern| pattern =~ warning.message } end ``` ## Contributing 1. Fork it ( http://github.com/Shopify/activerecord-pedantmysql2-adapter/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request