Db migrations 2

Added tests for the database migration procedure (https://bugs.launchpad.net/oq-engine/+bug/1294566).
Everything is green: https://ci.openquake.org/job/zdevel_oq-engine/570
Please check the necessity of ```from_scratch``` parameter is not needed in our infrastructure.