StringTemplate.Context refdata should be internal
Description
CSP Request Details
None
CSP Rejection Details
None
Potential Workaround
None
Checklist
hideActivity
Show:

Owen Stephens March 29, 2024 at 2:59 PM
The official bugfest system where I made the pre-upgrade changes has now been updated to mod-agreements 7.0.0 and the migrations seem to have run effectively and the StringTemplate.Context refdata is in the condition I’d expect given the edits I made before the migration
Given this seems to have worked without issues I'm closing this as DONE

Owen Stephens March 29, 2024 at 2:59 PM
The error reported below was from a rancher environment where they have now identified other issues with the setup. I think we can treat this as not able to be replicated for now

Owen Stephens March 28, 2024 at 12:19 PM
QA 28th March 2024: The migration fails with the error:
liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset add-quesnalia-indices-and-fk-constraints.groovy::20231128-1115-002::Jack_golding (manual):
Reason: org.postgresql.util.PSQLException: ERROR: column "strt_context" does not exist
Hint: Perhaps you meant to reference the column "string_template.strt_context_fk".

Owen Stephens March 21, 2024 at 3:11 PM
Changes made to the bugfest system pre-upgrade to Poppy:
Added a new value
Removed a default value
Changed the label for a default value

Jag Goraya February 19, 2024 at 11:11 AM
Deferred to BugFest Setup phase.
Done
Details
Details
Assignee

Reporter

Components
Priority
Sprint
None
Development Team
Bienenvolk
Release
Quesnelia (R1 2024)
RCA Group
TBD
Affected releases
Poppy (R2 2023)
Orchid (R1 2023)
Nolana (R3 2022)
TestRail: Cases
Open TestRail: Cases
TestRail: Runs
Open TestRail: Runs
Created October 13, 2023 at 11:04 AM
Updated March 29, 2024 at 2:59 PM
Resolved March 29, 2024 at 2:59 PM
TestRail: Cases
TestRail: Runs
Overview:
It should not be possible to delete values from the StringTemplate.Context refdata category in agreements
Steps to Reproduce:
Got to Settings -> Agreements -> Pick list values
Select StringTemplate.Context in pick list drop down
See that the values display with a trashcan icon
Expected Results:
No trashcan icon
Should be controlled with `@CategoryId(defaultInternal=true)` on the reference data category. Migration may also be needed to fix existing instances
Dev task breakdown
This is a multi step process:
Change domain class to make use of defaultInternal
Ensure we have no missing data:
Write migration for all missing entries (should be at most 2, unless something really funky has gone on)
Something like:
changeSet(author: "efreestone (manual)", id: "20210922-1534-002") { grailsChange { change { sql.eachRow(""" SELECT DISTINCT strt_context FROM ${database.defaultSchemaName}.string_template INNER JOIN ${database.defaultSchemaName}.refdata_value ON string_template.strt_context = refdata_value.rdv_id WHERE NOT EXISTS ( SELECT rdv_id FROM ${database.defaultSchemaName}.refdata_value WHERE rdv_id = strt_context )""".toString() ) { def row -> sql.execute(""" INSERT INTO ${database.defaultSchemaName}.refdata_value (rdv_id, rdv_version, rdv_value, rdv_owner, rdv_label) ${row.strt_context} as id, 0 as version, 'missing_context_${row.strt_context}' as value, ( SELECT rdc_id FROM ${database.defaultSchemaName}.refdata_category WHERE rdc_description='StringTemplate.Context' ) as owner, 'Missing context ${row.strt_context}' as label """.toString()) } } } }
This SQL and closure need testing, as I've written it without double checking it works. The top part should find all StringTemplate contexts which do not exist as refdata values, then pass those to the Closure below as "row", where we can use that in a different SQL query to insert a new refdata value with that id.
In this case (Not necessarily always true) we went from String -> refdata, so we should add a migration changing the column type from VARCHAR(255) to VARCHAR(36)
Add migration for foreign key constraint
Add migration changing defaultInternal to true for the refdata category