@@ -0,0 +1,1031 @@
+import logging%0Aimport sys%0A%0Afrom modularodm import Q%0A%0Afrom framework.mongo import database%0Afrom framework.transactions.context import TokuTransaction%0A%0Afrom website.app import init_app%0Afrom scripts import utils as script_utils%0A%0Alogger = logging.getLogger(__name__)%0A%0Adef migrate(dry_run=False):%0A    sns_collection = database%5B's3nodesettings'%5D%0A    logger.info('Migrating all %7B%7D S3NodeSettings documents: %7B%7D'.format(%0A        sns_collection.count(), %5Bs%5B'_id'%5D for s in sns_collection.find()%5D%0A    ))%0A    sns_collection.find_and_modify(%0A        %7B%7D,%0A        %7B'$rename': %7B'bucket': 'folder_id'%7D%0A    %7D)%0A%0A    # TODO: update folder_name with bucket location%0A%0A    if dry_run:%0A        raise RuntimeError('Dry run, transaction rolled back.')%0A%0Adef main():%0A    dry_run = False%0A    if '--dry' in sys.argv:%0A        dry_run = True%0A    if not dry_run:%0A        script_utils.add_file_logger(logger, __file__)%0A    init_app(set_backends=True, routes=False)%0A    with TokuTransaction():%0A        migrate(dry_run=dry_run)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add migration script