aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migration_tools.py
diff options
context:
space:
mode:
authorRodney Ewing <ewing.rj@gmail.com>2013-08-02 07:28:35 -0700
committerRodney Ewing <ewing.rj@gmail.com>2013-08-02 07:28:35 -0700
commitbf5a8e54524246b521ba30675b22a73e93288e8b (patch)
tree05522dae6a5acca8ab505805dd44f8c9c2629cb7 /mediagoblin/db/migration_tools.py
parent2119ee3b90446264db48f5259d8cce30e397dee3 (diff)
parent84c1cd7c52e7a07f2e0605433f255d946fe2737a (diff)
downloadmediagoblin-bf5a8e54524246b521ba30675b22a73e93288e8b.tar.lz
mediagoblin-bf5a8e54524246b521ba30675b22a73e93288e8b.tar.xz
mediagoblin-bf5a8e54524246b521ba30675b22a73e93288e8b.zip
Merge remote-tracking branch 'tilly-q/ticket-679'
Diffstat (limited to 'mediagoblin/db/migration_tools.py')
-rw-r--r--mediagoblin/db/migration_tools.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/mediagoblin/db/migration_tools.py b/mediagoblin/db/migration_tools.py
index aa22ef94..e75f3757 100644
--- a/mediagoblin/db/migration_tools.py
+++ b/mediagoblin/db/migration_tools.py
@@ -29,7 +29,7 @@ class MigrationManager(object):
to the latest migrations, etc.
"""
- def __init__(self, name, models, migration_registry, session,
+ def __init__(self, name, models, foundations, migration_registry, session,
printer=simple_printer):
"""
Args:
@@ -40,6 +40,7 @@ class MigrationManager(object):
"""
self.name = unicode(name)
self.models = models
+ self.foundations = foundations
self.session = session
self.migration_registry = migration_registry
self._sorted_migrations = None
@@ -140,6 +141,18 @@ class MigrationManager(object):
self.session.bind,
tables=[model.__table__ for model in self.models])
+ def populate_table_foundations(self):
+ """
+ Create the table foundations (default rows) as layed out in FOUNDATIONS
+ in mediagoblin.db.models
+ """
+ for Model, rows in self.foundations.items():
+ self.printer(u' + Laying foundations for %s table\n' %
+ (Model.__name__))
+ for parameters in rows:
+ new_row = Model(**parameters)
+ self.session.add(new_row)
+
def create_new_migration_record(self):
"""
Create a new migration record for this migration set
@@ -202,9 +215,9 @@ class MigrationManager(object):
self.init_tables()
# auto-set at latest migration number
- self.create_new_migration_record()
-
+ self.create_new_migration_record()
self.printer(u"done.\n")
+ self.populate_table_foundations()
self.set_current_migration()
return u'inited'