#NEWLINE# def migrate_useractivitycounters( dry_run = True ) : #NEWLINE# #INDENT# collection = db [ 'useractivitycounters' ] #NEWLINE# for counter in collection . find ( ) : #NEWLINE# #INDENT# _id = counter [ '_id' ] #NEWLINE# if ( collection == _id . lower ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# counter [ '_id' ] = _id . lower ( ) #NEWLINE# logging . debug ( 'Changing _id {} to {}' . format ( _id , _id . lower ( ) ) ) #NEWLINE# if ( not dry_run ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# collection . update ( { #NEWLINE# #INDENT# '_id' : _id . lower ( ) , #NEWLINE# #UNINDENT# } , counter , upsert = True ) #NEWLINE# #UNINDENT# except DuplicateKeyError : #NEWLINE# #INDENT# logging . debug ( 'Key exists' )