Move XMLDB upgrade helper functions into a new upgradelib

We can't rely on Moodle sourcing our plugin's library files for us, as
upgrade-related code tends to run in an extremely limited subset of the
Moodle environment for stability reasons.
Finally drop underscores

Finally closes #9