def set_version_db(apps, schema_editor):
 db_alias = schema_editor.connection.alias
 Version = apps.get_model(u'reversion', u'Version')
 content_types = Version.objects.using(db_alias).order_by().values_list(u'content_type_id', u'content_type__app_label', u'content_type__model').distinct()
 model_dbs = defaultdict(list)
 for (content_type_id, app_label, model_name) in content_types:
  try:
   model = live_apps.get_model(app_label, model_name)
  except LookupError:
   db = u'default'
  else:
   db = router.db_for_write(model)
  model_dbs[db].append(content_type_id)
 if ((DEFAULT_DB_ALIAS in model_dbs) and (len(model_dbs) == 1)):
  Version.objects.using(db_alias).update(db=DEFAULT_DB_ALIAS)
 else:
  for (db, content_type_ids) in model_dbs.items():
   Version.objects.using(db_alias).filter(content_type__in=content_type_ids).update(db=db)

def set_version_db ( apps , schema_editor ) : db_alias = schema_editor . connection . alias Version = apps . get_model ( u'reversion' , u'Version' ) content_types = Version . objects . using ( db_alias ) . order_by ( ) . values_list ( u'content_type_id' , u'content_type__app_label' , u'content_type__model' ) . distinct ( ) model_dbs = defaultdict ( list ) for ( content_type_id , app_label , model_name ) in content_types : try : model = live_apps . get_model ( app_label , model_name ) except LookupError : db = u'default' else : db = router . db_for_write ( model ) model_dbs [ db ] . append ( content_type_id ) if ( ( DEFAULT_DB_ALIAS in model_dbs ) and ( len ( model_dbs ) == 1 ) ) : Version . objects . using ( db_alias ) . update ( db = DEFAULT_DB_ALIAS ) else : for ( db , content_type_ids ) in model_dbs . items ( ) : Version . objects . using ( db_alias ) . filter ( content_type__in = content_type_ids ) . update ( db = db )
updates the db field in all version models to point to the correct write db for the model .