diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-03-04 10:57:21 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-03-04 10:57:21 -0600 |
commit | 7e4a87dca5c8afa13b64f76c4b9ce440d38a91b5 (patch) | |
tree | 84dc7393bc15af96c0c6c69498cf3a2d56d769de /mediagoblin/db/migration_tools.py | |
parent | 17e4679ddc4b6ee6d2be5a5e55ba9d314e5a1a42 (diff) | |
download | mediagoblin-7e4a87dca5c8afa13b64f76c4b9ce440d38a91b5.tar.lz mediagoblin-7e4a87dca5c8afa13b64f76c4b9ce440d38a91b5.tar.xz mediagoblin-7e4a87dca5c8afa13b64f76c4b9ce440d38a91b5.zip |
Give a more useful error if a table already exists and so we can't create it during migrations
This commit sponsored by Andrzej Prochyra. Thanks!
Diffstat (limited to 'mediagoblin/db/migration_tools.py')
-rw-r--r-- | mediagoblin/db/migration_tools.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mediagoblin/db/migration_tools.py b/mediagoblin/db/migration_tools.py index e5380a3b..c0c7e998 100644 --- a/mediagoblin/db/migration_tools.py +++ b/mediagoblin/db/migration_tools.py @@ -17,6 +17,9 @@ from mediagoblin.tools.common import simple_printer from sqlalchemy import Table +class TableAlreadyExists(Exception): + pass + class MigrationManager(object): """ @@ -128,7 +131,10 @@ class MigrationManager(object): # sanity check before we proceed, none of these should be created for model in self.models: # Maybe in the future just print out a "Yikes!" or something? - assert not model.__table__.exists(self.session.bind) + if model.__table__.exists(self.session.bind): + raise TableAlreadyExists( + u"Intended to create table '%s' but it already exists" % + model.__table__.name) self.migration_model.metadata.create_all( self.session.bind, |