diff --git a/tests/test_sql_upgrade.py b/tests/test_sql_upgrade.py index 156b420a8b..88eaaa8a68 100644 --- a/tests/test_sql_upgrade.py +++ b/tests/test_sql_upgrade.py @@ -81,6 +81,20 @@ class SqlUpgradeTests(test.TestCase): version = migration.db_version() self.assertEqual(version, 0, "DB is at version 0") + def test_two_steps_forward_one_step_back(self): + """You should be able to cleanly undo a re-apply all upgrades. + + Upgrades are run in the following order:: + + 0 -> 1 -> 0 -> 1 -> 2 -> 1 -> 2 -> 3 -> 2 -> 3 ... + ^---------^ ^---------^ ^---------^ + + """ + for x in range(1, self.max_version + 1): + self.upgrade(x) + self.downgrade(x - 1) + self.upgrade(x) + def assertTableColumns(self, table_name, expected_cols): """Asserts that the table contains the expected set of columns.""" table = self.select_table(table_name)