* Avoid lodash typecheks
Lodash is quite big project. Even with direct imports it loads [tons](https://github.com/knex/knex/pull/3804) of
code and still bloats node_modules. Especially since lodash mostly used
as a polyfill for modern features.
In this diff I attempted to reduce lodash usage by replacing type checks
with `typeof` operator which might be sufficient.
Also replaced lodash/isObject with custom simplified utility which does not
consider functions as objects and allows to simplify code in one place.
* knex methods are proxies for context methods ...
... as opposed to injecting the methods directly onto the knex
function. (Which was then causing `this` to point to the wrong
object when evaluating the context methods)
* Moved CONTEXT_METHODS constant to a higher scope
* mv knex.context -> this.context
* Extracted KNEX_PROPERTY_DEFINITIONS to module scope ...
... which was possible since all of the properties reference
`this` instead of `knex` now
* shallowCloneFunction no longer accesses _context ...
... instead, it uses the normal context property
* transaction method delegates to _transaction ...
... This way, we can be sure that the lower-level details are
consistent across implementations. Individual implementations
just need to handle the quirks around setting up the `config`
and `outerTx`
* CONTEXT_METHODS shared. Fixed override of withUserParams ...
Restructured the code so that CONTEXT_METHODS populates the
KNEX_PROPERTY_DEFINITIONS with the proxy methods.
In doing so, it also exposed the fact that the withUserParams(..)
method was being overridden on the Transactor instead of its
context. So, that bug was fixed as well.
* Added a TODO to remove client.makeKnex(..) in future PR
* Added a warning about QueryBuilder.extend(..) and side-effects
Returns 0 if all migrations are run and DB is up to date. Return negative number if DB is missing migrations. Return positive number if DB is ahead (rare case, e.g. if migrations were run then code is reverted)