From ff94114c5d19be45a674a36980be643e097f7f12 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 10 Jul 2011 22:50:03 -0500 Subject: [PATCH] Setup the application to record the database version if missing on launch --- mediagoblin/app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 9454b403..523b9302 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -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')) -- 2.25.1