From a650160390a5bb9d08976b3284135761ecc76ff0 Mon Sep 17 00:00:00 2001 From: Andres Guzman Date: Mon, 8 Jul 2024 15:49:29 -0600 Subject: [PATCH] fix(utils.py): change update to upsert --- litellm/proxy/management_helpers/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/management_helpers/utils.py b/litellm/proxy/management_helpers/utils.py index 1cf22480b0..3a0e8e4be8 100644 --- a/litellm/proxy/management_helpers/utils.py +++ b/litellm/proxy/management_helpers/utils.py @@ -29,9 +29,17 @@ async def add_new_member( """ ## ADD TEAM ID, to USER TABLE IF NEW ## if new_member.user_id is not None: - await prisma_client.db.litellm_usertable.update( + await prisma_client.db.litellm_usertable.upsert( where={"user_id": new_member.user_id}, - data={"teams": {"push": [team_id]}}, + data={ + "update": { + "teams": {"push": [team_id]} + }, + "create": { + "user_id": new_member.user_id, + "teams": [team_id] + } + }, ) elif new_member.user_email is not None: user_data = {"user_id": str(uuid.uuid4()), "user_email": new_member.user_email}