Fix direct inclusion of Knex instance in migrations

Knex doesn't create actual instances so checking whether a valid Knex client is an `instanceof require('knex')` fails. I'm borrowing the detection logic [from Bookshelf](https://github.com/tgriesser/bookshelf/blob/master/bookshelf.js#L37). Definitely planning to write tests for all this soon, but I can confirm that it works (migrations run) on a real project.