Skip to content
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

Create Task Upgrade to create new unique_field table #30275

Closed
Tracked by #29459
freddyDOTCMS opened this issue Oct 7, 2024 · 3 comments · Fixed by #30301
Closed
Tracked by #29459

Create Task Upgrade to create new unique_field table #30275

freddyDOTCMS opened this issue Oct 7, 2024 · 3 comments · Fixed by #30301

Comments

@freddyDOTCMS
Copy link
Contributor

freddyDOTCMS commented Oct 7, 2024

Parent Issue

#29459

User Story

According to spike #29707, the best solution to address the unique fields bug is to create a new table to store and validate all unique values. To implement this, we need to create a new Task Upgrade to create and populate this new unique_fields table.

New Table Structure

  • unique_key_val (bigint): A hash calculated by concatenating the following values: content_type, field_var, host_id, language, and value. The host_id is only included if the field variable uniquePerSite is set.
  • supporting_values (jsonb): A JSON object containing the following fields: content_type, field_var, host_id, language, value, uniquePerSite, and content_identifier. The content_identifier will be an array, as multiple contentlets may share the same value before the upgrade.

The unique_key_val is the PK of the table.

Populate New Table

We need to populate this new table with the unique field values that already exist in the system. The following query was used during the spike to retrieve these unique values:


SELECT DISTINCT 
    structure.velocity_var_name AS type_var_name,
    field.velocity_var_name AS field_var_name,
    contentlet.language_id,
    identifier.host_inode,
    jsonb_extract_path_text(contentlet_as_json->'fields', field.velocity_var_name)::jsonb->>'value' AS field_value
FROM contentlet
    INNER JOIN structure ON structure.inode = contentlet.structure_inode
    INNER JOIN field ON structure.inode = field.structure_inode
    INNER JOIN identifier ON contentlet.identifier = identifier.id
WHERE jsonb_extract_path_text(contentlet_as_json->'fields', field.velocity_var_name) IS NOT NULL

Required Update:

The query above does not yet account for the content_identifier and the uniquePerSite field variable. We need to update this query to support these fields for the final fix.

Acceptance Criteria

  • Create Task Upgrade to create/populate unique_fields table
  • Don't include the new Task Upgrade in TaskLocatorUtil, we are going to do this later

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

No response

Sub-Tasks & Estimates

No response

@freddyDOTCMS freddyDOTCMS moved this from New to Next 1-3 Sprints in dotCMS - Product Planning Oct 7, 2024
@freddyDOTCMS freddyDOTCMS self-assigned this Oct 7, 2024
@freddyDOTCMS freddyDOTCMS moved this from Next 1-3 Sprints to In Progress in dotCMS - Product Planning Oct 7, 2024
freddyDOTCMS added a commit that referenced this issue Oct 9, 2024
@freddyDOTCMS freddyDOTCMS moved this from In Progress to In Review in dotCMS - Product Planning Oct 10, 2024
freddyDOTCMS added a commit that referenced this issue Oct 10, 2024
jgambarios pushed a commit that referenced this issue Oct 11, 2024
…30301)

### Proposed Changes
* Create new Task Upgrade to create and popualate the new unique_fields
table

Create


https://github.com/dotCMS/core/pull/30301/files#diff-93fb205d6a0d941cfc0933bbfbfc3dd5bc70723d3fc8a8513f8058939ec7f901R113

and populate


https://github.com/dotCMS/core/pull/30301/files#diff-93fb205d6a0d941cfc0933bbfbfc3dd5bc70723d3fc8a8513f8058939ec7f901R116

it is not add in the TaskLocatorUtil, I am going to it in a future PR

---------

Co-authored-by: spbolton <[email protected]>
@freddyDOTCMS freddyDOTCMS removed their assignment Oct 11, 2024
@freddyDOTCMS
Copy link
Contributor Author

Note to QA: The task hasn't been added to the TaskLocatorUtil yet, so you'll need to run it manually or add it for QA testing. Please don't push this change for now. It's important to check during IQA if the unique_tables are being populated correctly, to check the table popualte you are going to need to execute the query directly into the Database.

I think QA is not need here because the whole fix is still a Work in progress.

@dsilvam dsilvam self-assigned this Oct 14, 2024
@dsilvam
Copy link
Contributor

dsilvam commented Oct 14, 2024

Passed IQA.

Executed the upgrade task via postman and checked the columns and the data of the new table.

Image
Image

@dsilvam dsilvam moved this from Internal QA to QA - Backlog in dotCMS - Product Planning Oct 14, 2024
@josemejias11
Copy link
Contributor

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

@josemejias11 josemejias11 moved this from QA - In Progress to Done in dotCMS - Product Planning Oct 15, 2024
@dsilvam dsilvam closed this as completed Oct 16, 2024
@github-project-automation github-project-automation bot moved this from Done to Internal QA in dotCMS - Product Planning Oct 16, 2024
@dsilvam dsilvam moved this from Internal QA to Done in dotCMS - Product Planning Oct 16, 2024
spbolton added a commit that referenced this issue Nov 11, 2024
…30301)

### Proposed Changes
* Create new Task Upgrade to create and popualate the new unique_fields
table

Create


https://github.com/dotCMS/core/pull/30301/files#diff-93fb205d6a0d941cfc0933bbfbfc3dd5bc70723d3fc8a8513f8058939ec7f901R113

and populate


https://github.com/dotCMS/core/pull/30301/files#diff-93fb205d6a0d941cfc0933bbfbfc3dd5bc70723d3fc8a8513f8058939ec7f901R116

it is not add in the TaskLocatorUtil, I am going to it in a future PR

---------

Co-authored-by: spbolton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants