Fixes in the schema migration code

Note: it also contains the patch from https://github.com/crowbar/barclamp-crowbar/pull/699