Skip to content

[Team Deletions] Migration: add team deletion schedule - #6611

Open
aerosol wants to merge 2 commits into
masterfrom
team-sites-deletions-migration
Open

[Team Deletions] Migration: add team deletion schedule#6611
aerosol wants to merge 2 commits into
masterfrom
team-sites-deletions-migration

Conversation

@aerosol

@aerosol aerosol commented Aug 20, 2026

Copy link
Copy Markdown
Member

This isn't final form, but an initial base migration for tracking/audting team deletions life cycle (expired trials, cancelled subscriptions).

Discussion: https://3.basecamp.com/5308029/buckets/44692882/messages/10216872798

Backported from the team-sites-deletions-intervals branch, where the
team_deletion_schedules status enum's `:deleted` value was renamed to
`:completed` - keeping the partial unique index's WHERE clause in sync.
@aerosol aerosol changed the title Migration: add team deletion schedule [Team Deletions] Migration: add team deletion schedule Aug 24, 2026
:team_deletion_schedules,
[:team_id],
unique: true,
where: "status NOT IN ('cancelled', 'completed')",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is status: 'completed' different from the row being deleted via cascade from the teams table deletion?

@aerosol aerosol Aug 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't delete the team, we delete its sites. The team stays and remains still available for upgrade. Does that make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to support the case when the team subscribes for a month and then cancels only to renew next year

@ukutaht ukutaht Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Ignore stuff below, I didn't see your reply before posting. I am slightly surprised by that – I was assuming we delete the team. But if that's agreed with @metmarkosaric then all good.

Thinking about the lifecycle after reading https://github.com/plausible/analytics/pull/6615/changes#r3852893234

When a deletion is executed, I'm assuming the team will be deleted and it cascades to this table automatically.

Is there a planned lifecycle state where the team still exists but the deletion schedule is in completed state?

If there is a use-case for this state, the sync_eligible function does not seem to account for that. In case team exists and deletion schedule is completed, it looks like another deletion schedule will be created (or is this intended?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ukutaht we just planned to delete dashboards and stats. accounts and teams we don't touch. it's mostly sites/stats that affect us in terms of data storage/backups and CS while it seems nice for people to keep access to their account, team setup, subscription history etc. it also makes it easier to come back and start again if/when needed

@ukutaht ukutaht Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm but if we only delete sites then won't the churned customer be on a never-ending cycle of deletions?

  1. sync_eligible finds a churned customer with no active deletion schedule
  2. Deletion schedule is created
  3. Email notifications go out
  4. Sites are deleted
  5. Deletion schedule status is changed to completed
  6. GOTO step 1

or am I missing something that prevents this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah @ukutaht that's a valid observation. I'll address that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a nice catch overall, I think what we should do is to ensure at least one site exists for a team in order to fulfill the eligibility check. That way already completed deletion sweeps exist as audit entries and don't loop, unless a new site is created (which implies subscription must go through its cycle again). Does that make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 14f4f0b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants