Throw DBMigrationError instead of DbMigrationError.

Stop throwing the deprecated DbMigrationError exception,
Use the new DBMigrationError exception instead,
so that the consumers can catch the new exception.
DbMigrationError will not be removed until no consumers
still use it.

Change-Id: Iab0566cf9f4552e91fa417e64472fa106e8bc86d
This commit is contained in:
Yaguo Zhou 2017-09-08 11:54:09 +08:00
parent e9a9701d54
commit 9a5a3b3395
2 changed files with 4 additions and 4 deletions

View File

@ -78,7 +78,7 @@ def db_sync(engine, abs_path, version=None, init_version=0, sanity_check=True):
try:
migration = versioning_api.upgrade(engine, repository, version)
except Exception as ex:
raise exception.DbMigrationError(ex)
raise exception.DBMigrationError(ex)
else:
migration = versioning_api.downgrade(engine, repository,
version)

View File

@ -195,16 +195,16 @@ class TestMigrationCommon(test_base.DbTestCase):
@mock.patch.object(versioning_api, 'upgrade')
def test_db_sync_script_not_present(self, upgrade):
# For non existent migration script file sqlalchemy-migrate will raise
# VersionNotFoundError which will be wrapped in DbMigrationError.
# VersionNotFoundError which will be wrapped in DBMigrationError.
upgrade.side_effect = migrate_exception.VersionNotFoundError
self.assertRaises(db_exception.DbMigrationError,
self.assertRaises(db_exception.DBMigrationError,
migration.db_sync, self.engine, self.path,
self.test_version + 1)
@mock.patch.object(versioning_api, 'upgrade')
def test_db_sync_known_error_raised(self, upgrade):
upgrade.side_effect = migrate_exception.KnownError
self.assertRaises(db_exception.DbMigrationError,
self.assertRaises(db_exception.DBMigrationError,
migration.db_sync, self.engine, self.path,
self.test_version + 1)