Correctly determine if migration is needed.

This method would assume that if last migration in the migrations
directory matched the current schema version, that the database was up
to date, but this does not account for new migrations with older
timestamps that may be pending.
Merge pull request #16349 from jmcnevin/master

Correctly determine if migration is needed.