5.0.0 to 5.1DEV_13 upgrade script

This will need rebasing on top of the upgrade
script from Blazej once merged.