⚡ Optimized performance of integrity check DB calls
⚡ Optimized performance of integrity check DB calls

refs https://github.com/TryGhost/knex-migrator/issues/252

- the referenced issue describes performance problems with the integrity check code in knex-migrator
- this commit solves half of the problem - 1 DB call per migration minor version folder
- this results in 70+ (and growing!) DB calls at boot, with each one going back and forth to the DB... not efficient
- what the code actually needed was a count of how many migrations are currently in the DB, grouped by version - this is very easy to do in SQL and therefore knex
- this commit switches the code around to group all the DB migrations first, and then compares against the folders locally
- this results in a drop of SQL queries from 70+ to 1 🚀

TryGhost/knex-migrator