From: Christopher Allan Webber Date: Mon, 11 Jul 2011 03:50:03 +0000 (-0500) Subject: Setup the application to record the database version if missing on launch X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ff94114c5d19be45a674a36980be643e097f7f12;p=mediagoblin.git Setup the application to record the database version if missing on launch --- 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'))