refactored data upgrade tests in test_migrations

The one off testing in test_migrations was starting to get obtuse
enough that it was possible for bugs to slip through (which they
did already). Create a more general framework for testing data
transitions at any db migration.

Hook the walk_versions code so as we are about to upgrade to a
migration point, attempt to run a _prerun_### function, then follow
it up with a _check_### function afterwards. Create some utility
functions to make doing things in these _prerun and _check functions
pretty concise.

This makes these checks db independent, and has it so they'll run
however we are running the walk_versions.

In doing so, this uncovered a bug in the 147 migration, which is
fixed inline. There is no retroactive fix, as 147 was destructive to
data, so would have nuked anyone that hit it already.

Updated to remove safe_getattr, thanks to jerdfelt for pointer on
doing that right.

Partially implements blueprint migration-testing-with-data

Fixes bug #1108448

Change-Id: I8bd92e3688109bfbdf1da21a175055b7263abf45
Merge "refactored data upgrade tests in test_migrations"
Merge remote-tracking branch 'citrix/master' into build-temp