Skip to content

Reduce dependencies on activity and revisions tables#23612

Merged
ComfortablyCoding merged 16 commits intomainfrom
retentions-p1
Oct 16, 2024
Merged

Reduce dependencies on activity and revisions tables#23612
ComfortablyCoding merged 16 commits intomainfrom
retentions-p1

Conversation

@licitdev
Copy link
Member

@licitdev licitdev commented Sep 9, 2024

Scope

What's changed:

  • Extracted comments to a separate table
  • Consolidated content versioning

Potential Risks / Drawbacks

  • 2 new migrations were added

Review Notes / Questions

  • This PR allows for the future removal of legacy behaviour for comments and version

P1 for issue #23166
Closes SER-268

licitdev and others added 2 commits September 6, 2024 13:54
* Add directus_comments migration

* Add comments controller and service

* Remove from activity

* Update system-data and types

* Refactor app with new endpoints

* Expose service

* Update app minimal permissions

* Add collection translation

* Define relations

* Allow comment creation only if there's item read access

* Patch for MSSQL double constraints issue

* Fix users service test

* Add sdk support

* Update specs

* Fix formatting

* Fix specs error

* Patch whoopsie

* Remove obsolete GraphQL mutations

* Update required fields

* Remove unused vars

* Allow edit and delete of legacy activity comments

* Remove legacy comments from SDK

* Add changeset

* Batch upwards migration

* Update SDK to use keysOrQuery

Co-authored-by: Brainslug <[email protected]>

* Update implementation for keysOrQuery

* Remove singleton check

* Update SDK to use keysOrQuery 2

Co-authored-by: Brainslug <[email protected]>

* Update keysOrQuery typedoc

* Fix import

* Update migration timestamp

* fixed import

* Update api/src/utils/get-service.ts

* utilize chunk processing in migration

* formatting

* only services extended from itemservice should be added

* remove redundant checks from comment header

* update comment service to v11 permission format

* specify missing required fields

* Mock comments in users test

* Simplify migration and update date

* WIP legacy access

* Optimise imports

* WIP app cleanup

* Update loadUserPreviews typing

Co-authored-by: Daniel Biegler <[email protected]>

* Read legacy comments

* Parse using comments service

* Perform migration directly

* Fix legacy app sort query which uses id

* Migrate legacy comments in mutations

* Reduce api semver

* Update app recommended permissions

* Recommend updating of comment only

* replace hardcoded type with existing one

* Allow users to update or delete their own comments

Co-authored-by: daedalus <[email protected]>

* Skip further access validation for non-existent collections

* Check if collection exists before the admin check

Co-authored-by: daedalus <[email protected]>

* Fix incorrect legacy check

Co-authored-by: Daniel Biegler <[email protected]>

* Fix merging of count when db returns count as string type

* Remove unused import

---------

Co-authored-by: Brainslug <[email protected]>
Co-authored-by: Pascal Jufer <[email protected]>
Co-authored-by: Brainslug <[email protected]>
Co-authored-by: daedalus <[email protected]>
Co-authored-by: Daniel Biegler <[email protected]>
* Add migration

* Use the new delta field

* Add cast-json flag

* Fix typing

* Fetch existing deltas if version created during migration

* Add changeset

* Add version delta field into sdk schema

* Update migration timestamp

* Update versions.save() to return finalVersionDelta

Co-authored-by: Pascal Jufer <[email protected]>

* Sort on DB level

* Update migration date

* Disallow passing delta via create/update

* Update docs & specs

* Fix save response

* Remove unnecessary access check

Already checked by the subsequent itemsService.readOne call

* Update changeset

* Don't require update perms on versions for save

* Optimize validateCreateData

* update to new validateAccess

* Update docs/reference/system/versions.md

* Remove migration of delta

* Rename to legacy

* Add missed changes for Remove migration of delta in 2e2f50f

* Update docs/reference/system/versions.md

---------

Co-authored-by: Pascal Jufer <[email protected]>
Co-authored-by: daedalus <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2024

🦋 Changeset detected

Latest commit: 5e291ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@directus/api Minor
@directus/sdk Major
@directus/system-data Minor
@directus/specs Minor
@directus/types Minor
@directus/app Minor
directus Patch
@directus/composables Patch
@directus/utils Patch
@directus/extensions-sdk Patch
@directus/extensions Patch
@directus/themes Patch
@directus/validation Patch
@directus/env Patch
@directus/extensions-registry Patch
@directus/memory Patch
@directus/pressure Patch
@directus/storage-driver-azure Patch
@directus/storage-driver-cloudinary Patch
@directus/storage-driver-gcs Patch
@directus/storage-driver-s3 Patch
@directus/storage-driver-supabase Patch
create-directus-extension Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ComfortablyCoding ComfortablyCoding marked this pull request as ready for review October 15, 2024 20:35
@ComfortablyCoding ComfortablyCoding self-assigned this Oct 15, 2024
@ComfortablyCoding ComfortablyCoding self-requested a review October 16, 2024 13:30
Copy link
Member

@ComfortablyCoding ComfortablyCoding left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ComfortablyCoding ComfortablyCoding merged commit 189fcb2 into main Oct 16, 2024
@ComfortablyCoding ComfortablyCoding deleted the retentions-p1 branch October 16, 2024 13:33
@github-actions github-actions bot added this to the Next Release milestone Oct 16, 2024
vwasteels pushed a commit to Agence-Indivisible/directus that referenced this pull request Dec 5, 2024
* Extract comments to a separate table (directus#22295)

* Add directus_comments migration

* Add comments controller and service

* Remove from activity

* Update system-data and types

* Refactor app with new endpoints

* Expose service

* Update app minimal permissions

* Add collection translation

* Define relations

* Allow comment creation only if there's item read access

* Patch for MSSQL double constraints issue

* Fix users service test

* Add sdk support

* Update specs

* Fix formatting

* Fix specs error

* Patch whoopsie

* Remove obsolete GraphQL mutations

* Update required fields

* Remove unused vars

* Allow edit and delete of legacy activity comments

* Remove legacy comments from SDK

* Add changeset

* Batch upwards migration

* Update SDK to use keysOrQuery

Co-authored-by: Brainslug <[email protected]>

* Update implementation for keysOrQuery

* Remove singleton check

* Update SDK to use keysOrQuery 2

Co-authored-by: Brainslug <[email protected]>

* Update keysOrQuery typedoc

* Fix import

* Update migration timestamp

* fixed import

* Update api/src/utils/get-service.ts

* utilize chunk processing in migration

* formatting

* only services extended from itemservice should be added

* remove redundant checks from comment header

* update comment service to v11 permission format

* specify missing required fields

* Mock comments in users test

* Simplify migration and update date

* WIP legacy access

* Optimise imports

* WIP app cleanup

* Update loadUserPreviews typing

Co-authored-by: Daniel Biegler <[email protected]>

* Read legacy comments

* Parse using comments service

* Perform migration directly

* Fix legacy app sort query which uses id

* Migrate legacy comments in mutations

* Reduce api semver

* Update app recommended permissions

* Recommend updating of comment only

* replace hardcoded type with existing one

* Allow users to update or delete their own comments

Co-authored-by: daedalus <[email protected]>

* Skip further access validation for non-existent collections

* Check if collection exists before the admin check

Co-authored-by: daedalus <[email protected]>

* Fix incorrect legacy check

Co-authored-by: Daniel Biegler <[email protected]>

* Fix merging of count when db returns count as string type

* Remove unused import

---------

Co-authored-by: Brainslug <[email protected]>
Co-authored-by: Pascal Jufer <[email protected]>
Co-authored-by: Brainslug <[email protected]>
Co-authored-by: daedalus <[email protected]>
Co-authored-by: Daniel Biegler <[email protected]>

* Consolidate content versioning (directus#22413)

* Add migration

* Use the new delta field

* Add cast-json flag

* Fix typing

* Fetch existing deltas if version created during migration

* Add changeset

* Add version delta field into sdk schema

* Update migration timestamp

* Update versions.save() to return finalVersionDelta

Co-authored-by: Pascal Jufer <[email protected]>

* Sort on DB level

* Update migration date

* Disallow passing delta via create/update

* Update docs & specs

* Fix save response

* Remove unnecessary access check

Already checked by the subsequent itemsService.readOne call

* Update changeset

* Don't require update perms on versions for save

* Optimize validateCreateData

* update to new validateAccess

* Update docs/reference/system/versions.md

* Remove migration of delta

* Rename to legacy

* Add missed changes for Remove migration of delta in 2e2f50f

* Update docs/reference/system/versions.md

---------

Co-authored-by: Pascal Jufer <[email protected]>
Co-authored-by: daedalus <[email protected]>

* Update migration dates

* api change should be major for versioning

* Remove comment paths from activity reference

* Added comments reference

* Added directus_comments to table of system collections

* The linter demands newline

* Revert function renaming for patch semver

* Use transaction in down migration for comments (directus#23715)

---------

Co-authored-by: Brainslug <[email protected]>
Co-authored-by: Pascal Jufer <[email protected]>
Co-authored-by: Brainslug <[email protected]>
Co-authored-by: daedalus <[email protected]>
Co-authored-by: Daniel Biegler <[email protected]>
Co-authored-by: Kevin Lewis <[email protected]>
Co-authored-by: Rijk van Zanten <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants