code: def use_database(cls, database):
          
          original_database = getattr(cls, 'database', None)
          impacted_models = super(RelatedModel, cls).use_database(database)
  
          # no relation on the current database, so nothing nore to transfer
          if not original_database or not getattr(original_database, '_relations', {}):
              return impacted_models
  
          # prepare relations to remove impacted ones
          # relations in original_database._relations have this format
          # related_model => (original_model, original_field, related_name)
          # Here we want all relations with an original_model in our list of
          # models impacted by the change of database (impacted_models), to move
          # these relation on the new database
          reverse_relations = {}
          for related_model_name, relations in original_database._relations.items():
              for relation in relations:
                  reverse_relations.setdefault(relation[0], []).append((related_model_name, relation))
  
          # create an dict to store relations in the new database
          if not hasattr(database, '_relations'):
              database._relations = {}
  
          # move relation for all impacted models
          for _model in impacted_models:
              if _model.abstract:
                  continue
              for related_model_name, relation in reverse_relations[_model._name]:
                  # if the related model name is already used as a relation, check
                  # if it's not already used with the related_name of the relation
                  if related_model_name in database._relations:
                      field = _model.get_field(relation[1])
                      field._assert_relation_does_not_exists()
                  # move the relation from the original database to the new
                  original_database._relations[related_model_name].remove(relation)
                  database._relations.setdefault(related_model_name, []).append(relation)
  
          return impacted_models
docs: Move model and its submodels to the new database, as the original
          use_database method. And manage relations too (done here instead of
          the database because the database class is not aware of relations)