def METHOD_NAME(apps, schema_editor):
    AuthUser = apps.get_model("auth", "User")
    AuditUser = apps.get_model("audit", "AuditUser")
    AuditLog = apps.get_model("audit", "AuditLog")
    AuditSession = apps.get_model("audit", "AuditSession")
    for auth_user in AuthUser.objects.filter(is_active=True):
        AuditUser.objects.get_or_create(
            username=auth_user.username, created_at=auth_user.date_joined, auth_user_id=auth_user.pk
        )
    auditlog_usernames = [
        username
        for username in AuditLog.objects.values_list("user__username", flat=True).distinct()
        if username is not None
    ]
    auth_user_pks = [AuthUser.objects.get(username=username).pk for username in auditlog_usernames]
    for log_username, auth_pk in zip(auditlog_usernames, auth_user_pks):
        audit_user, created = AuditUser.objects.get_or_create(username=log_username)
        if created:
            audit_user.created_at = AuthUser.objects.get(username=log_username).date_joined
            audit_user.auth_user_id = auth_pk
            audit_user.save(update_fields=["created_at", "auth_user_id"])
        AuditLog.objects.filter(user__username=log_username).update(audit_user=audit_user)
    auditsession_usernames = [
        username
        for username in AuditSession.objects.values_list("user__username", flat=True).distinct()
        if username is not None
    ]
    auth_user_pks = [AuthUser.objects.get(username=username).pk for username in auditsession_usernames]
    for session_username, auth_pk in zip(auditsession_usernames, auth_user_pks):
        audit_user, created = AuditUser.objects.get_or_create(username=session_username)
        if created:
            audit_user.created_at = AuthUser.objects.get(username=session_username).date_joined
            audit_user.auth_user_id = auth_pk
            audit_user.save(update_fields=["created_at", "auth_user_id"])
        AuditSession.objects.filter(user__username=session_username).update(audit_user=audit_user)