Test that you can undo & re-apply all migrations

Change-Id: I72e2b979a8692657c225102f2562e1b1fbb3f67d
Allow running of sql against the live DB.

Reordered the tables in the domain downgrade script to avoid breaking the integrity constraints

To run the test:
./run_tests.sh -N  test_sql_upgrade

This version removed all of the code specific to running against a live DB and merged it into the
standard tests.

Fixed a couple downgrade functions that were failing.  They had not
been tested

Change-Id: Ie1214e5543bd08fde95652af2464cc9c80db449d
Merge "Allow running of sql against the live DB."
Merge "Test that you can undo & re-apply all migrations"