diff options
Diffstat (limited to 'mediagoblin/gmg_commands')
-rw-r--r-- | mediagoblin/gmg_commands/migrate.py | 9 | ||||
-rw-r--r-- | mediagoblin/gmg_commands/mongosql.py | 7 | ||||
-rw-r--r-- | mediagoblin/gmg_commands/wipealldata.py | 8 |
3 files changed, 18 insertions, 6 deletions
diff --git a/mediagoblin/gmg_commands/migrate.py b/mediagoblin/gmg_commands/migrate.py index cacf5d19..af541786 100644 --- a/mediagoblin/gmg_commands/migrate.py +++ b/mediagoblin/gmg_commands/migrate.py @@ -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) diff --git a/mediagoblin/gmg_commands/mongosql.py b/mediagoblin/gmg_commands/mongosql.py index a25263e2..dd53f575 100644 --- a/mediagoblin/gmg_commands/mongosql.py +++ b/mediagoblin/gmg_commands/mongosql.py @@ -14,12 +14,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from mediagoblin.db.sql.convert import run_conversion - def mongosql_parser_setup(subparser): pass 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) diff --git a/mediagoblin/gmg_commands/wipealldata.py b/mediagoblin/gmg_commands/wipealldata.py index 3081bbc0..37217fd1 100644 --- a/mediagoblin/gmg_commands/wipealldata.py +++ b/mediagoblin/gmg_commands/wipealldata.py @@ -20,12 +20,16 @@ import sys import os import shutil +from mediagoblin.init import setup_global_and_app_config + def wipe_parser_setup(subparser): pass def wipe(args): + global_config, app_config = setup_global_and_app_config(args.conf_file) + print "*** WARNING! ***" print "" print "Running this will destroy your mediagoblin database," @@ -39,12 +43,12 @@ def wipe(args): 'Are you **SURE** you want to destroy your environment? ' '(if so, type "yes")> ') - if not drop_it == 'yes': + if drop_it != 'yes': return print "nixing data in mongodb...." conn = pymongo.Connection() - conn.drop_database('mediagoblin') + conn.drop_database(app_config["db_name"]) for directory in [os.path.join(os.getcwd(), "user_dev", "media"), os.path.join(os.getcwd(), "user_dev", "beaker")]: |