aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migration_tools.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/db/migration_tools.py')
-rw-r--r--mediagoblin/db/migration_tools.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/mediagoblin/db/migration_tools.py b/mediagoblin/db/migration_tools.py
index aa22ef94..1192836d 100644
--- a/mediagoblin/db/migration_tools.py
+++ b/mediagoblin/db/migration_tools.py
@@ -140,6 +140,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
+ """
+ from mediagoblin.db.models import FOUNDATIONS as MAIN_FOUNDATIONS
+ for Model, rows in MAIN_FOUNDATIONS.items():
+ print u'\n--> Laying foundations for %s table' % Model.__name__
+ for parameters in rows:
+ row = Model(**parameters)
+ row.save()
+
def create_new_migration_record(self):
"""
Create a new migration record for this migration set
@@ -202,7 +214,9 @@ class MigrationManager(object):
self.init_tables()
# auto-set at latest migration number
- self.create_new_migration_record()
+ self.create_new_migration_record()
+ if self.name==u'__main__':
+ self.populate_table_foundations()
self.printer(u"done.\n")
self.set_current_migration()