bug: Deleting a team leaves its websites orphaned (no owner, invisible in the UI, still collecting data)
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_atstaysNULL); - 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
-
As user A, create a team and add a website to it (or transfer an existing website to the team).
-
Delete the team from the UI.
-
Go to the Websites list as user A (the former team owner): the website is gone.
-
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.
-
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:
- 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.
- Transfer to the team owner: on delete, set
user_idto the team owner and notify them ("N websites were transferred to you"). - 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
i can work on this @zft9xgy
Fixed in v3.5