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

ERM-3387: Description can be too long for index, causing mod-licenses error when updating from 5.0.x to later versions or failure on saving licenses with a long description #272

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
databaseChangeLog = {
/* GIN Indexes have been added in update-mod-licenses-5-1.groovy
* These can cause issues when the underlying data passes a certain limit
* due to trigram operator not being used and the postgres token size growing
*
* It is a little unorthodox, however these index creations are conditional on
* "CREATE IF NOT EXISTS". We will make use of that to insert indices on those
* fields _before_ they are set up by upgrading/new implementors. For any tenants
* who already managed to upgrade, these new changesets will be ignored, but it
* it _recommended_ that an operational task be undertaken to bring those schemas
* in line with the indices in place on new instances of mod-agreements
*/

// The first two of these shouldn't be impacted by the bug outlined in ERM-3387, but we bring them in line anyway
changeSet(author: "EFreestone (manual)", id: "2024-10-17-ERM-3387-quesnalia-1") {
preConditions (onFail: 'MARK_RAN', onError: 'WARN') {
not {
indexExists(tableName: 'alternate_name', columnNames: 'an_name')
}
}
// Gin indexes need to be done via scripting.
grailsChange {
change {
def cmd = "CREATE INDEX alternate_name_name_idx ON ${database.defaultSchemaName}.alternate_name USING gin (an_name gin_trgm_ops);".toString()
sql.execute(cmd);
}
}
}

changeSet(author: "EFreestone (manual)", id: "2024-10-17-ERM-3387-quesnalia-2") {
preConditions (onFail: 'MARK_RAN', onError: 'WARN') {
not {
indexExists(tableName: 'license', columnNames: 'lic_name')
}
}
grailsChange {
change {
def cmd = "CREATE INDEX license_name_idx ON ${database.defaultSchemaName}.license USING gin (lic_name gin_trgm_ops);".toString()
sql.execute(cmd);
}
}
}

changeSet(author: "EFreestone (manual)", id: "2024-10-17-ERM-3387-quesnalia-3") {
preConditions (onFail: 'MARK_RAN', onError: 'WARN') {
not {
indexExists(tableName: 'license', columnNames: 'lic_description')
}
}
grailsChange {
change {
def cmd = "CREATE INDEX license_description_idx ON ${database.defaultSchemaName}.license USING gin (lic_description gin_trgm_ops);".toString()
sql.execute(cmd);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ databaseChangeLog = {
include file: 'wtk/hidden-appsetting.feat.groovy'
include file: 'update-mod-license-4-2.groovy'
include file: 'wtk/multi-value-custprops.feat.groovy'
include file: 'correct-gin-indices-pre-quesnalia.groovy'
include file: 'update-mod-license-5-1.groovy'
}