-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update cleaning suspended workspace job #9999
Conversation
etiennejouan
commented
Feb 4, 2025
- split workspace metadata deletion into multiple queries
- delete all subscriptions when workspace is deleted
baacdeb
to
5412cf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR enhances workspace deletion by implementing a more thorough cleanup process for workspace metadata and subscriptions.
- Added deletion of field and relation metadata through new TypeORM repositories in
packages/twenty-server/src/engine/workspace-manager/workspace-manager.service.ts
- Modified
deleteSubscription
todeleteSubscriptions
inpackages/twenty-server/src/engine/core-modules/billing/services/billing-subscription.service.ts
to remove all workspace-associated subscriptions - Implemented ordered metadata deletion (relations → fields → objects → migrations → data source → schema) in workspace-manager service for proper referential integrity
- Added FieldMetadataEntity and RelationMetadataEntity to WorkspaceManagerModule's metadata connection
4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
} | ||
await this.billingSubscriptionRepository.delete({ workspaceId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This bulk delete operation could potentially leave orphaned BillingSubscriptionItems. Consider cascading the delete or explicitly cleaning up related subscription items.
} | ||
await this.billingSubscriptionRepository.delete({ workspaceId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i follow: which additional billingSubscriptions could we have ? why do we not need to cancel them too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A workspace can have multiple subscriptions but only one in a not canceled status. (If workspace users have a subscription, cancel it and then subscribe again. Workspace has two subscriptions)
So when a workspace is deleted, we check if there is a not canceled subscription, if yes, we cancel it (in stripe) and then we delete all subscriptions (all in canceled status) in db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very clear thank you !
Log
|
- split workspace metadata deletion into multiple queries - delete all subscriptions when workspace is deleted --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>