Skip to content

Extract comments to a separate table#22295

Merged
DanielBiegler merged 69 commits intoretentions-p1from
directus-comments
Sep 6, 2024
Merged

Extract comments to a separate table#22295
DanielBiegler merged 69 commits intoretentions-p1from
directus-comments

Conversation

@licitdev
Copy link
Member

@licitdev licitdev commented Apr 23, 2024

Scope

What's changed:

  • A new directus_comments table for comments

Potential Risks / Drawbacks

  • Existing users reading into comments outside of the data studio will have to update their usage

Review Notes / Questions

  • Activity and revisions now exist for tracking
  • Additional logic is added in the API to support legacy app queries to update comments
  • A migration is required in a subsequent version to migrate legacy comments in directus_activity to directus_comments
  • A legacy comment is only migrated into directus_comments when it is updated or deleted
  • The legacy app usage can be tested by building the app from main and accessing it from the dev api server in this PR

Related to #17894

Closes SER-255

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2024

🦋 Changeset detected

Latest commit: 47791b9

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

@licitdev licitdev changed the title Extract comments to separate table Extract comments to a separate table Apr 24, 2024
@licitdev licitdev marked this pull request as ready for review April 26, 2024 08:39
@licitdev licitdev requested review from br41nslug and paescuj April 26, 2024 08:41
@licitdev licitdev marked this pull request as ready for review August 21, 2024 16:32
@ComfortablyCoding
Copy link
Member

ComfortablyCoding commented Sep 3, 2024

LGTM 🚀

Some things to note:

  1. For older comments the ID changes from a number (from revisions table) to a UUID (from comments table) on first update after API code changes. This can lead to confusion for subsequent updates if the user attempts to use the old (number) id a second time. Effect should be minimal as the app does account for this.
  2. The non-existent collection Internal Server error fix in a12b49b applies only to non admin users, for admin accounts this check is bypassed altogether and results in a Foreign Key error.

P.S. Left off approval as I was not sure if #2 was expected or not

@licitdev licitdev changed the base branch from main to retentions-p1 September 3, 2024 15:43
Copy link
Contributor

@DanielBiegler DanielBiegler left a comment

Choose a reason for hiding this comment

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

After the latest rounds of changes it worked for me, lets move on to the testing branch

@DanielBiegler DanielBiegler merged commit 6cb0ac1 into retentions-p1 Sep 6, 2024
@DanielBiegler DanielBiegler deleted the directus-comments branch September 6, 2024 11:54
ComfortablyCoding added a commit that referenced this pull request Oct 16, 2024
* Extract comments to a separate table (#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 (#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 (#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 Nov 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants