diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-05-22 10:52:53 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-05-22 10:52:53 -0500 |
commit | 757f37a52d7854ed752d56c66498383125a05a9f (patch) | |
tree | a37befe4e85e70cb6d4e65293998bc6e567d5317 /mediagoblin/gmg_commands/migrate.py | |
parent | 8820121ad125728613477f3dec098aa2df5f47ac (diff) | |
download | mediagoblin-757f37a52d7854ed752d56c66498383125a05a9f.tar.lz mediagoblin-757f37a52d7854ed752d56c66498383125a05a9f.tar.xz mediagoblin-757f37a52d7854ed752d56c66498383125a05a9f.zip |
User migration works (but the rest of the system isn't updated for new user setup yet)
Diffstat (limited to 'mediagoblin/gmg_commands/migrate.py')
-rw-r--r-- | mediagoblin/gmg_commands/migrate.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/mediagoblin/gmg_commands/migrate.py b/mediagoblin/gmg_commands/migrate.py new file mode 100644 index 00000000..e04fb343 --- /dev/null +++ b/mediagoblin/gmg_commands/migrate.py @@ -0,0 +1,45 @@ +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011 Free Software Foundation, Inc +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# 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 import migrations +from mediagoblin.gmg_commands import util as commands_util +from mediagoblin import globals as mgoblin_globals + + +def migrate_parser_setup(subparser): + subparser.add_argument( + '-cf', '--conf_file', default='mediagoblin.ini', + help="Config file used to set up environment") + subparser.add_argument( + '-cs', '--app_section', default='app:mediagoblin', + help="Section of the config file where the app config is stored.") + + +def migrate(args): + mgoblin_app = commands_util.setup_app(args) + print "Applying migrations..." + + for model_name in migrations.MIGRATE_CLASSES: + model = getattr(mgoblin_app.db, model_name) + + if not hasattr(model, 'migration_handler') or not model.collection: + continue + + migration = model.migration_handler(model) + migration.migrate_all(collection=model.collection) + + print "... done." |