enable_strict_mode? base.class_eval do def configure_connection_with_sql_mode configure_connection_without_sql_mode execute("SET @@SESSION.sql_mode = 'STRICT_ALL_TABLES'", :skip_logging) end alias_method_chain :configure_connection, :sql_mode end end end end ActiveSupport.on_load(:active_record) do ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, SetStrictSqlMode) end