dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
866 stars 467 forks source link

When the 'uniquePerSite' is set recalculate unique_fields key values #30281

Open freddyDOTCMS opened 1 month ago

freddyDOTCMS commented 1 month ago

Parent Issue

29459

User Story

If in a unique fields the uniquePerSite field variable is changed then be need recalculated the unique_key hash values for the unique_table, to include or exclude the host id according to the new value.

We need to create a API/Factory methods to do this.

Acceptance Criteria

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

Steps to Reproduce:

No response

Sub-Tasks & Estimates

No response

github-actions[bot] commented 1 week ago

PRs:

victoralfaro-dotcms commented 5 days ago

Tested in dotcms/dotcms:trunk_e9c8559 After run curl command:

{"entity":"Ran the upgrade task: com.dotmarketing.startup.runonce.Task241007CreateUniqueFieldsTable","errors":[],"i18nMessagesMap":{},"messages":[],"pagination":null,"permissions":[]}

Logs:

dotcms-app-1  | 21:32:08.615  INFO  system.UpgradeTaskResource - Running the upgrade task: com.dotmarketing.startup.runonce.Task241007CreateUniqueFieldsTable
dotcms-app-1  | 21:32:08.703  INFO  system.UpgradeTaskResource - Ran the upgrade task: com.dotmarketing.startup.runonce.Task241007CreateUniqueFieldsTable

A Content Type was created with two fields: Title and Site. For the Title field we defined a field variable called uniquePerSite and it was set to true. Created a new site. Created two contents (of the recent created Content Type) one the demo.dotcms.com site and the other in the new site. Went to edit the Content Type and tried to delete uniquePerSite field variable. Error message when trying to delete the uniquePerSite field variable when there was already a content with the same unique field in a different site.

image

SHA before changes: d5c4e3130c61fd48ef51f5ac666d590d6186b77e24bbf76667960a2aee4694ae After manually removing the record holding the same unique field the deletion of the field variable was allowed and therefore the hash was recalculated. SHA after changes: 8db02dab81f332cf6bb24babbb39253063ce6569db7e32c3ced5758b9789d9ec

JSON after changes

image
josemejias11 commented 3 days ago

Approved: Tested on trunk_e15f58e, Docker, macOS 14.5, FF v126.0.1