Setup the application to record the database version if missing on launch
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 11 Jul 2011 03:50:03 +0000 (22:50 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 11 Jul 2011 03:50:03 +0000 (22:50 -0500)
mediagoblin/app.py

index 9454b40348f802e632a4ca25d44b79f96749c249..523b930289b77d9de2cb648fad998d6829244f3f 100644 (file)
@@ -24,6 +24,7 @@ from mediagoblin import routing, util, storage, staticdirect
 from mediagoblin.init.config import (
     read_mediagoblin_config, generate_validation_report)
 from mediagoblin.db.open import setup_connection_and_db_from_config
+from mediagoblin.db.util import MigrationManager
 from mediagoblin.mg_globals import setup_globals
 from mediagoblin.init.celery import setup_celery_from_config
 from mediagoblin.init import get_jinja_loader
@@ -71,6 +72,16 @@ class MediaGoblinApp(object):
         self.connection, self.db = setup_connection_and_db_from_config(
             app_config)
 
+        # Init the migration number if necessary
+        migration_manager = MigrationManager(self.db)
+        migration_manager.install_migration_version_if_missing()
+
+        # Tiny hack to warn user if our migration is out of date
+        if not migration_manager.database_at_latest_migration():
+            print (
+                "*WARNING:* Your migrations are out of date, "
+                "maybe run ./bin/gmg migrate?")
+
         # Get the template environment
         self.template_loader = get_jinja_loader(
             app_config.get('user_template_path'))