diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-01-29 16:58:58 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-01-29 16:58:58 -0600 |
commit | f3791a9490f7dca7eaadc8229e31fe7285823d12 (patch) | |
tree | b3af94d99d05e2bea89fa003869de2ba0821dd3f | |
parent | 0f3526c601b7848a54808ec0baef832d3baaa8b7 (diff) | |
download | mediagoblin-f3791a9490f7dca7eaadc8229e31fe7285823d12.tar.lz mediagoblin-f3791a9490f7dca7eaadc8229e31fe7285823d12.tar.xz mediagoblin-f3791a9490f7dca7eaadc8229e31fe7285823d12.zip |
A few basic fixes to sql/util.py
- MigrationRecord to MigrationData, again
- If the table doesn't exist, return None for database_current_migration
- database.engine -> database.bind
-rw-r--r-- | mediagoblin/db/sql/util.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mediagoblin/db/sql/util.py b/mediagoblin/db/sql/util.py index d9ce7d2b..604ea19c 100644 --- a/mediagoblin/db/sql/util.py +++ b/mediagoblin/db/sql/util.py @@ -93,6 +93,10 @@ class MigrationManager(object): """ Return the current migration in the database. """ + # If the table doesn't even exist, return None. + if not self.migration_table.exists(self.database.bind): + return None + return self.migration_data.version def set_current_migration(self, migration_number): @@ -129,7 +133,7 @@ class MigrationManager(object): assert not model.__table__.exists(self.database) self.migration_model.metadata.create_all( - self.database.engine, + self.database.bind, tables=[model.__table__ for model in self.models]) def create_new_migration_record(self): @@ -253,8 +257,8 @@ def assure_migrations_table_setup(db): """ Make sure the migrations table is set up in the database. """ - from mediagoblin.db.sql.models import MigrationRecord + from mediagoblin.db.sql.models import MigrationData - if not MigrationRecord.__table__.exists(db.engine): - MigrationRecord.metadata.create_all( - db, tables=[MigrationRecord.__table__]) + if not MigrationData.__table__.exists(db.bind): + MigrationData.metadata.create_all( + db, tables=[MigrationData.__table__]) |