1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 Free Software Foundation, Inc
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 from mediagoblin
.db
import migrations
19 from mediagoblin
.gmg_commands
import util
as commands_util
22 def migrate_parser_setup(subparser
):
23 subparser
.add_argument(
24 '-cf', '--conf_file', default
='mediagoblin.ini',
25 help="Config file used to set up environment")
29 mgoblin_app
= commands_util
.setup_app(args
)
30 print "Applying migrations..."
32 for model_name
in migrations
.MIGRATE_CLASSES
:
33 model
= getattr(mgoblin_app
.db
, model_name
)
35 if not hasattr(model
, 'migration_handler') or not model
.collection
:
38 migration
= model
.migration_handler(model
)
39 migration
.migrate_all(collection
=model
.collection
)