re-add pocock's code from 10/13, with enhancements/holes for future impr...

...ovement
There is already a version comparison algorithm in the [compareversion](https://github.com/xtuple/xtuple/blob/4_7_x/foundation-database/public/functions/compareversion.sql) function.