diff --git a/ee/api/chalicelib/core/users.py b/ee/api/chalicelib/core/users.py index b85346ad1..b55600da2 100644 --- a/ee/api/chalicelib/core/users.py +++ b/ee/api/chalicelib/core/users.py @@ -528,7 +528,7 @@ def delete_member(user_id, tenant_id, id_to_delete): with pg_client.PostgresClient() as cur: cur.execute( cur.mogrify(f"""UPDATE public.users - SET deleted_at = timezone('utc'::text, now()) + SET deleted_at = timezone('utc'::text, now()), role_id=NULL WHERE user_id=%(user_id)s AND tenant_id=%(tenant_id)s;""", {"user_id": id_to_delete, "tenant_id": tenant_id})) cur.execute( diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql index a144f3a1d..7feee11a8 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql @@ -63,4 +63,8 @@ $$ LANGUAGE plpgsql; ALTER TABLE IF EXISTS sessions ADD COLUMN IF NOT EXISTS file_key BYTEA DEFAULT NULL; +UPDATE users +SET role_id=NULL +WHERE deleted_at IS NOT NULL; + COMMIT; \ No newline at end of file