Merge branch 'RED-10482-bp2' into 'release/2.465.x'

RED-10482: Indices not created correctly via liquibase

See merge request redactmanager/persistence-service!869
This commit is contained in:
Maverick Studer 2024-11-14 18:26:28 +01:00
commit fa381c6249
10 changed files with 4 additions and 566 deletions

View File

@ -1,10 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">
<include file="/mongo/changelog/tenant/1-initial-database.changelog.xml"/>
<include file="/mongo/changelog/tenant/2-create-indices-for-entries.xml"/>
<include file="/mongo/changelog/tenant/3-add-page-paragraph-idx.xml"/>
<include file="/mongo/changelog/tenant/4-create-component-entities.xml"/>
<include file="/mongo/changelog/tenant/5-add-duplicate-text-ranges.xml"/>
</databaseChangeLog>

View File

@ -1,224 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="createEntityLogEntryCollection" author="maverick">
<ext:createCollection collectionName="entity-log-entries">
<ext:options>
{
validator: {
$jsonSchema: {
bsonType: "object",
required: ["entryId", "entityLogId", "type", "entryType", "state", "value", "reason", "matchedRule", "legalBasis", "containingNodeId", "closestHeadline", "section",
"positions", "textBefore", "textAfter", "startOffset", "endOffset", "imageHasTransparency", "dictionaryEntry", "dossierDictionaryEntry", "excluded", "changes",
"manualChanges", "engines", "reference", "importedRedactionIntersections", "numberOfComments"],
properties: {
entryId: {
bsonType: "string",
description: "The Entry ID"
},
entityLogId: {
bsonType: "string",
description: "The Entity Log ID"
},
type: {
bsonType: "string",
description: "The Type"
},
entryType: {
bsonType: "string",
description: "The Entry Type"
},
state: {
bsonType: "string",
description: "The Entry State"
},
value: {
bsonType: "string",
description: "The Value"
},
reason: {
bsonType: "string",
description: "The Reason"
},
matchedRule: {
bsonType: "string",
description: "The Matched Rule"
},
legalBasis: {
bsonType: "string",
description: "The Legal Basis"
},
containingNodeId: {
bsonType: "array",
items: {
bsonType: "int",
description: "The Containing Node ID"
}
},
closestHeadline: {
bsonType: "string",
description: "The Closest Headline"
},
section: {
bsonType: "string",
description: "The Section"
},
positions: {
bsonType: "array",
description: "The Positions",
items: {
bsonType: "object"
}
},
textBefore: {
bsonType: "string",
description: "Text before the entry"
},
textAfter: {
bsonType: "string",
description: "Text after the entry"
},
startOffset: {
bsonType: "int",
description: "Start offset of the entry"
},
endOffset: {
bsonType: "int",
description: "End offset of the entry"
},
imageHasTransparency: {
bsonType: "bool",
description: "Whether the image has transparency"
},
dictionaryEntry: {
bsonType: "bool",
description: "Whether it's a dictionary entry"
},
dossierDictionaryEntry: {
bsonType: "bool",
description: "Whether it's a dossier dictionary entry"
},
excluded: {
bsonType: "bool",
description: "Whether it's excluded"
},
changes: {
bsonType: "array",
description: "The Changes",
items: {
bsonType: "object"
}
},
manualChanges: {
bsonType: "array",
description: "The Manual Changes",
items: {
bsonType: "object"
}
},
engines: {
bsonType: "array",
description: "The Engines",
items: {
bsonType: "string"
}
},
reference: {
bsonType: "array",
description: "The Reference",
items: {
bsonType: "string"
}
},
importedRedactionIntersections: {
bsonType: "array",
description: "The Imported Redaction Intersections",
items: {
bsonType: "string"
}
},
numberOfComments: {
bsonType: "int",
description: "The Number of Comments"
}
}
}
},
validationAction: "warn",
validationLevel: "strict"
}
</ext:options>
</ext:createCollection>
<ext:createCollection collectionName="entity-logs">
<ext:options>
{
validator: {
$jsonSchema: {
bsonType: "object",
required: ["dossierId", "fileId", "analysisVersion", "analysisNumber", "entityLogEntryDocument", "legalBasis"],
properties: {
dossierId: {
bsonType: "string",
description: "The Dossier ID"
},
fileId: {
bsonType: "string",
description: "The File ID"
},
analysisVersion: {
bsonType: "long",
description: "The Analysis Version"
},
analysisNumber: {
bsonType: "int",
description: "The Analysis Number"
},
entityLogEntryDocument: {
bsonType: "array",
description: "The Entity Log Entry Documents",
items: {
bsonType: "objectId"
}
},
legalBasis: {
bsonType: "array",
description: "The Legal Basis",
items: {
bsonType: "object"
}
},
dictionaryVersion: {
bsonType: "long",
description: "The Dictionary Version"
},
dossierDictionaryVersion: {
bsonType: "long",
description: "The Dossier Dictionary Version"
},
rulesVersion: {
bsonType: "long",
description: "The Rules Version"
},
legalBasisVersion: {
bsonType: "long",
description: "The Legal Basis Version"
}
}
}
},
validationAction: "warn",
validationLevel: "strict"
}
</ext:options>
</ext:createCollection>
</changeSet>
</databaseChangeLog>

View File

@ -1,17 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="createEntityLogEntryCollection" author="maverick">
<ext:createCollection collectionName="entity-log-entries"/>
<ext:createCollection collectionName="entity-logs"/>
</changeSet>
</databaseChangeLog>

View File

@ -1,48 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="createIndicesForEntries" author="maverick">
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
}
</ext:keys>
<ext:options>
{name: "entityLogId_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"positions.pageNumber": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_positionsPageNumber_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"containingNodeId": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_containingNodeId_index"}
</ext:options>
</ext:createIndex>
</changeSet>
</databaseChangeLog>

View File

@ -1,25 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="3" author="aisvoran">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $set: { "paragraphPageIdx": -1 } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -1,106 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="createComponentCollection" author="ali">
<ext:createCollection collectionName="component-logs">
<ext:options>
{
"collMod": "component-logs",
"validator": {
"$jsonSchema": {
"bsonType": "object",
"required": ["id", "dossierId", "fileId", "analysisNumber", "componentRulesVersion", "components"],
"properties": {
"id": {
"bsonType": "string",
"description": "must be a string and is required"
},
"dossierId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"fileId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"analysisNumber": {
"bsonType": "int",
"description": "must be an integer and is required"
},
"componentRulesVersion": {
"bsonType": "long",
"description": "must be a long and is required"
},
"components": {
"bsonType": "array",
"items": {
"bsonType": "objectId",
"description": "must be an array of objectIds"
},
"description": "must be an array and is required"
}
}
}
},
"validationLevel": "strict",
"validationAction": "error"
}
</ext:options>
</ext:createCollection>
<ext:createCollection collectionName="component-log-entries">
<ext:options>
{
"collMod": "component-log-entries",
"validator": {
"$jsonSchema": {
"bsonType": "object",
"required": ["id", "componentLogId", "name", "overrideValues", "values", "overridden"],
"properties": {
"id": {
"bsonType": "string",
"description": "must be a string and is required"
},
"componentLogId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"name": {
"bsonType": "string",
"description": "must be a string and is required"
},
"overrideValues": {
"bsonType": "array",
"items": {
"bsonType": "object"
},
"description": "must be an array of objects and is required"
},
"values": {
"bsonType": "array",
"items": {
"bsonType": "object"
},
"description": "must be an array of objects and is required"
},
"overridden": {
"bsonType": "bool",
"description": "must be a boolean and is required"
}
}
}
},
"validationLevel": "strict",
"validationAction": "warn"
}
</ext:options>
</ext:createCollection>
</changeSet>
</databaseChangeLog>

View File

@ -1,25 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="add-duplicate-text-ranges" author="aisvoran">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $set: { "duplicatedTextRanges": [] } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -1,84 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="createIndicesForEntries" author="maverick">
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
}
</ext:keys>
<ext:options>
{name: "entityLogId_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"positions.pageNumber": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_positionsPageNumber_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"changes.analysisNumber": -1
}
</ext:keys>
<ext:options>
{name: "entityLogId_changesAnalysisNumber_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"containingNodeId": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_containingNodeId_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"id": 1,
"containingNodeId": 1
}
</ext:keys>
<ext:options>
{name: "id_containingNodeId_index"}
</ext:options>
</ext:createIndex>
<ext:createIndex collectionName="entity-log-entries">
<ext:keys>
{
"entityLogId": 1,
"type": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_type_index"}
</ext:options>
</ext:createIndex>
</changeSet>
</databaseChangeLog>

View File

@ -1,26 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="1" author="maverick">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $unset: { "numberOfComments": "" } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -9,7 +9,10 @@ dependencies {
api(project(":persistence-service-shared-api-v1"))
api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.16.0")
api("com.google.guava:guava:31.1-jre")
api("com.knecon.fforesight:mongo-database-commons:0.10.0")
api("com.knecon.fforesight:mongo-database-commons:0.10.0"){
exclude(group = "com.knecon.fforesight", module = "tenant-commons")
exclude(group = "org.liquibase.ext", module = "liquibase-mongodb")
}
api("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootStarterVersion}")
api("org.springframework.boot:spring-boot-starter-validation:3.1.3")
testImplementation("com.iqser.red.commons:test-commons:2.1.0")