umami icon indicating copy to clipboard operation
umami copied to clipboard

bug: Deleting a team leaves its websites orphaned (no owner, invisible in the UI, still collecting data)

Open zft9xgy opened this issue 2 months ago • 2 comments

Describe the bug

When a team is deleted, the websites that belonged to it are not deleted, not transferred and not flagged. They end up with both team_id and user_id set to NULL, so no user owns them anymore:

  • they disappear from every user's website list, including the team owner's;
  • they are not soft-deleted (deleted_at stays NULL);
  • all their data (sessions, events) remains in the database;
  • the tracker keeps accepting events for them, so they keep collecting data that nobody can see.

The UI gives no warning that the team still owns websites, and it doesn't offer to transfer them. For the user it looks like the analytics were deleted, when they are actually sitting in the database with no way to reach them from the UI.

Steps to reproduce

  1. As user A, create a team and add a website to it (or transfer an existing website to the team).

  2. Delete the team from the UI.

  3. Go to the Websites list as user A (the former team owner): the website is gone.

  4. Query the database:

    select website_id, name, user_id, team_id, deleted_at
    from website
    where user_id is null and team_id is null;
    

    The website is still there, with no owner and no deletion flag.

  5. Load a page that has the tracking script: new events keep arriving for that website_id.

Expected behavior

Deleting a team should never leave a website without an owner. Any of these would work:

  1. Block or warn: if the team still owns websites, show them in the confirmation dialog and require transferring or deleting them first. This is the least surprising option.
  2. Transfer to the team owner: on delete, set user_id to the team owner and notify them ("N websites were transferred to you").
  3. Delete explicitly: if the websites are meant to go with the team, soft-delete them (deleted_at) and say so in the confirmation dialog, so the tracker stops collecting data for them.

What happens now is the worst case: the data is kept, it is still being collected, and nobody can see it.

Actual behavior

team_id is set to NULL and user_id stays NULL. Websites that belong to a team never have a user_id, so after the delete they have no owner at all.

Workaround

Reassign the orphaned website directly in the database:

update website
   set user_id = '<owner-user-id>', updated_at = now()
 where website_id = '<website-id>'
   and user_id is null and team_id is null;

After this the website shows up again with all of its historical data.

Environment

  • Umami 3.4.0, self-hosted with Docker (official image)
  • PostgreSQL 15
  • Single instance, not cloud mode

Database

PostgreSQL

Relevant log output


Which Umami version are you using?

3.4.0

How are you deploying your application?

Docker official image

Which browser are you using?

Firefox

zft9xgy avatar Sep 25 '26 11:09 zft9xgy

i can work on this @zft9xgy

akkki007 avatar Sep 26 '26 03:09 akkki007

Fixed in v3.5

franciscao633 avatar Nov 12 '26 17:11 franciscao633