mongo->sql conversion script now runs mongo migrations first, just in case
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 17 Mar 2012 22:08:46 +0000 (17:08 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 17 Mar 2012 22:08:46 +0000 (17:08 -0500)
mediagoblin/gmg_commands/migrate.py
mediagoblin/gmg_commands/mongosql.py

index cacf5d191122d48015aed01476d19264dac79e9a..af5417863bae75c4ead9ae81806d28a5f90a45f7 100644 (file)
@@ -17,7 +17,7 @@
 import sys
 
 from mediagoblin.db.mongo import util as db_util
-from mediagoblin.db.open import setup_connection_and_db_from_config
+from mediagoblin.db.mongo.open import setup_connection_and_db_from_config
 from mediagoblin.init import setup_global_and_app_config
 
 # This MUST be imported so as to set up the appropriate migrations!
@@ -41,7 +41,12 @@ def _print_finished_migration(migration_number, migration_func):
 
 
 def migrate(args):
-    global_config, app_config = setup_global_and_app_config(args.conf_file)
+    run_migrate(args.conf_file)
+
+
+def run_migrate(conf_file):
+    global_config, app_config = setup_global_and_app_config(conf_file)
+
     connection, db = setup_connection_and_db_from_config(
         app_config, use_pymongo=True)
     migration_manager = db_util.MigrationManager(db)
index 81a2830cbf2d48bf5019a5e2bd0d6207a1e9b64d..dd53f575e22be2b5404bdd1e507202bd25f0d01a 100644 (file)
@@ -20,5 +20,9 @@ def mongosql_parser_setup(subparser):
 
 
 def mongosql(args):
+    # First, make sure our mongo migrations are up to date...
+    from mediagoblin.gmg_commands.migrate import run_migrate
+    run_migrate(args.conf_file)
+
     from mediagoblin.db.sql.convert import run_conversion
     run_conversion(args.conf_file)