Skip to content

Commit

Permalink
ERM-3387: Description can be too long for index, causing mod-licenses…
Browse files Browse the repository at this point in the history
… error when updating from 5.0.x to later versions or failure on saving licenses with a long description (#272)

* fix: Pre-quesnalia gin index declarations

Included a migrations file to run pre-quesnalia migrations. This ensures that any systems coming from Poppy or before with sufficiently large license descriptions can upgrade to Q. Any systems who have _already_ upgraded to Q will have the "wrong" index on license description, and we recommend implementors manage the adding of the correct indexes manually

ERM-3387

* fix: Syntax error

Accidentally included a comma, that causes broken migrations.

Also realised that `"2024-10-17-ERM-3387-quesnalia-1"` and `"2024-10-17-ERM-3387-quesnalia-2"` are not currently running due to preconditions, which likely means the "wrong" gin index definitions are also not running even on systems which successfully upgraded to Q, so the license description really is the only one which matters

ERM-3387
  • Loading branch information
EthanFreestone authored Oct 18, 2024
1 parent c3876ab commit 2899f41
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
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'
}

0 comments on commit 2899f41

Please sign in to comment.