(PDB-4636) run-migrations: move pending-migration lookup inside txn
(PDB-4636) run-migrations: move pending-migration lookup inside txn

Arguably more appropriate (though still perhaps not sufficient to
fully protect migrations), and prepares for some broader migration
protections.

puppetlabs/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb