aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2012-01-02 08:55:25 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2012-01-29 16:33:45 -0600
commit8bf3f63af14152099d653e426aa22c1c4e487943 (patch)
treed49eb9cbf0f093a7888c7996c693a9c112757b52
parent3635ccdf346ceea12358a410a39f6edb34255182 (diff)
downloadmediagoblin-8bf3f63af14152099d653e426aa22c1c4e487943.tar.lz
mediagoblin-8bf3f63af14152099d653e426aa22c1c4e487943.tar.xz
mediagoblin-8bf3f63af14152099d653e426aa22c1c4e487943.zip
Added init_tables method to MigrationManager
-rw-r--r--mediagoblin/db/sql/util.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mediagoblin/db/sql/util.py b/mediagoblin/db/sql/util.py
index db66776d..59e8eb8b 100644
--- a/mediagoblin/db/sql/util.py
+++ b/mediagoblin/db/sql/util.py
@@ -121,8 +121,16 @@ class MigrationManager(object):
def init_tables(self):
- ## TODO
- pass
+ """
+ Create all tables relative to this package
+ """
+ # sanity check before we proceed, none of these should be created
+ for model in self.models:
+ assert not model.__table__.exists(self.database)
+
+ self.migration_model.metadata.create_all(
+ self.database,
+ tables=[model.__table__ for model in self.models])
def create_new_migration_record(self):
## TODO
@@ -163,6 +171,8 @@ class MigrationManager(object):
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None)
"""
+ assure_migrations_table_setup(self.database)
+
# Find out what migration number, if any, this database data is at,
# and what the latest is.
migration_number = self.database_current_migration()