Changed the call to .sort.last to .max when computing the migration version

Sorting then picking the last item incurs more cost than just finding the max. I've changed it so that when the current migration version is called, we use ``max`` instead of ``sort.last``.