-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: soft delete #6576
feat: soft delete #6576
Conversation
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
The pull request introduces soft delete functionality across various modules and entities, ensuring records are marked as deleted without being permanently removed from the database.
- GraphQL Schema Updates:
packages/twenty-front/src/generated-metadata/graphql.ts
updated to support new mutations and enums for soft delete. - Migration Script:
packages/twenty-server/src/database/typeorm/metadata/migrations/1723038077987-addSoftDelete.ts
adds asoftDelete
column to theobjectMetadata
table. - Service Modifications:
packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts
updated to handlesoftDelete
infindMany
,findOne
,deleteMany
, anddeleteOne
methods. - Entity Updates:
packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
andpackages/twenty-server/src/engine/twenty-orm/base.workspace-entity.ts
updated to includesoftDelete
anddeletedAt
fields. - Decorator Enhancements:
packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-object.decorator.ts
updated to include asoftDelete
option.
24 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings
...wenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/engine/twenty-orm/base.workspace-entity.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/database/typeorm/metadata/migrations/1723038077987-addSoftDelete.ts
Outdated
Show resolved
Hide resolved
icon: 'IconCalendarMinus', | ||
}) | ||
@WorkspaceIsNullable() | ||
deletedAt?: Date | null; |
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.
When I look at a production workspace it seems this column was created already by I don't understand why!? I'm missing something
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.
Hmm, on custom and standard objects ? I'm not having them on my computer
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.
@FelixMalfait @magrinj probably because it's defined there as a default column for custom table creation https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/utils/custom-table-default-column.util.ts
Originally I even put in the migration-runner in advance so it would have affected standard objects as well (and probably why you see some in prod) but it has been removed after many refactoring of this part I guess.
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.
that was my initial assumption but then why aren't position or name also created on every table?
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.
Even for recent standard objects from v0.23 I see deletedAt
column but I don't see position
(e.g. NoteTarget)
...-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
Outdated
Show resolved
Hide resolved
@magrinj it seems your filter is only on the first level of the queries. |
1e2e094
to
dff602f
Compare
packages/twenty-front/src/modules/views/components/SortOrFilterChip.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/views/components/VariantFilterChip.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/object-filter-dropdown/types/Filter.ts
Outdated
Show resolved
Hide resolved
// Why do we have two types, Filter and ViewFilter? | ||
// Why key defition is already present in the Filter type and added on the fly here with mapViewFiltersToFilters ? | ||
// Also as filter is spread into viewFilter, definition is present | ||
// FixMe: Ugly hack to make it work |
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.
@lucasbordeau or @charlesBochet maybe you have context on this?
TODO : invalidate cache of trashed items query when an item is deleted? If I go to trash, then delete an item, then go back to trash, that item doesn't show up |
Also I suspect It's not a blocker for merge, I think we should merge asap, even with this, and create a follow-up issue. |
Working, I'm merging like this but we should review the following things :
|
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
(updates since last review)
This pull request continues the implementation of soft delete functionality for standard and custom objects in the Twenty application. Key changes include:
- Added new resolver factories
DestroyManyResolverFactory
andRestoreManyResolverFactory
to support soft delete operations. - Implemented
InformationBannerDeletedRecord
component for displaying and managing deleted records in the UI. - Updated query builders and resolvers to handle soft-deleted records, including new
withSoftDeleted
options. - Refactored settings pages for improved navigation and consistency across the application.
- Removed
ExecuteQuickActionOnOneResolverFactory
, suggesting a shift away from quick actions in favor of the new soft delete approach.
Key points to note:
- New
destroyMany
andrestoreMany
operations added to support soft delete functionality. - UI components updated to handle and display soft-deleted records, improving user experience.
- Query builders now consider
isSoftDeletable
flag when constructing queries. - Settings pages reorganized for better navigation, with consistent use of icons and breadcrumbs.
- Removal of quick action related code suggests a significant change in how record actions are handled.
298 file(s) reviewed, 24 comment(s)
Edit PR Review Bot Settings
.../src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
Show resolved
Hide resolved
.../src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
Show resolved
Hide resolved
packages/twenty-front/src/modules/information-banner/constants/InformationBannerHeight.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/hooks/useDestroyManyRecords.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/hooks/useRestoreManyRecords.ts
Show resolved
Hide resolved
...ver/src/engine/api/graphql/workspace-query-builder/factories/relation-field-alias.factory.ts
Show resolved
Hide resolved
...ver/src/engine/api/graphql/workspace-query-builder/factories/relation-field-alias.factory.ts
Show resolved
Hide resolved
...ver/src/engine/api/graphql/workspace-query-builder/factories/relation-field-alias.factory.ts
Show resolved
Hide resolved
.../twenty-server/src/engine/api/graphql/workspace-query-runner/utils/with-soft-deleted.util.ts
Show resolved
Hide resolved
.../twenty-server/src/engine/api/graphql/workspace-query-runner/utils/with-soft-deleted.util.ts
Show resolved
Hide resolved
Thanks a lot @lucasbordeau!!!! Great if you can do the followups or at least create issues to make sure we don't forget any |
Implement soft delete on standards and custom objects.
This is a temporary solution, when we drop
pg_graphql
we should rely on thesoftDelete
functions of TypeORM.