From decba6a48091d76ba3ed3c87d30f4375f017c8a7 Mon Sep 17 00:00:00 2001 From: Deepak Joseph Date: Tue, 17 Dec 2024 13:27:04 +0530 Subject: [PATCH] Updated the column names after KIE discussions --- .../org/kie/kogito/index/jpa/model/NodeEntity.java | 4 ++-- .../index/jpa/model/ProcessDefinitionEntity.java | 4 ++-- ...45.0.7__modify_columns_with_reserved_words.sql} | 8 ++++---- ...45.0.7__modify_columns_with_reserved_words.sql} | 8 ++++---- .../persistence/postgresql/model/CacheEntity.java | 8 ++++---- .../V1.5.1__modify_columns_with_reserved_words.sql | 3 ++- .../src/main/resources/cache_entity_create.sql | 6 +++--- .../V1.5.1__modify_columns_with_reserved_words.sql | 3 ++- .../postgresql/reporting/BasicTypeMappingIT.java | 10 +++++----- .../ComplexHierarchicalTypeMappingIT.java | 10 +++++----- .../reporting/HierarchicalTypeMappingIT.java | 10 +++++----- .../reporting/api/PostgresMappingsApiV1IT.java | 4 ++-- .../PostgresApplyMappingSqlBuilderIT.java | 14 +++++++------- .../src/test/resources/bootstrap.json | 12 ++++++------ 14 files changed, 53 insertions(+), 51 deletions(-) rename data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/{V1.45.0.6__modify_columns_with_reserved_words.sql => V1.45.0.7__modify_columns_with_reserved_words.sql} (89%) rename data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/{V1.45.0.6__modify_columns_with_reserved_words.sql => V1.45.0.7__modify_columns_with_reserved_words.sql} (80%) diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java index f5df6bab66..f11c3d2b47 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java @@ -53,8 +53,8 @@ public class NodeEntity extends AbstractEntity { @CollectionTable(name = "definitions_nodes_metadata", joinColumns = { @JoinColumn(name = "node_id", referencedColumnName = "id"), @JoinColumn(name = "process_id", referencedColumnName = "process_id"), @JoinColumn(name = "process_version", referencedColumnName = "process_version") }, foreignKey = @ForeignKey(name = "fk_definitions_nodes_metadata_definitions_nodes")) - @MapKeyColumn(name = "metadata_key") - @Column(name = "metadata_value") + @MapKeyColumn(name = "name") + @Column(name = "meta_value") private Map metadata; @Id diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java index 36251279d3..a7158f31bb 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java @@ -78,8 +78,8 @@ public class ProcessDefinitionEntity extends AbstractEntity { @CollectionTable(name = "definitions_metadata", joinColumns = { @JoinColumn(name = "process_id", referencedColumnName = "id"), @JoinColumn(name = "process_version", referencedColumnName = "version") }, foreignKey = @ForeignKey(name = "fk_definitions_metadata")) - @MapKeyColumn(name = "metadata_key") - @Column(name = "metadata_value") + @MapKeyColumn(name = "name") + @Column(name = "meta_value") private Map metadata; @Override diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.6__modify_columns_with_reserved_words.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql similarity index 89% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.6__modify_columns_with_reserved_words.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql index 016f0bc997..fd92ea6208 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.6__modify_columns_with_reserved_words.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql @@ -17,8 +17,8 @@ * under the License. */ -alter table definitions_nodes_metadata alter column key rename to metadata_key; -alter table definitions_nodes_metadata alter column value rename to metadata_value; -alter table definitions_metadata alter column key rename to metadata_key; -alter table definitions_metadata alter column value rename to metadata_value; +alter table definitions_nodes_metadata alter column key rename to name; +alter table definitions_nodes_metadata alter column value rename to meta_value; +alter table definitions_metadata alter column key rename to name; +alter table definitions_metadata alter column value rename to meta_value; alter table definitions_annotations alter column value rename to annotation; diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.6__modify_columns_with_reserved_words.sql b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql similarity index 80% rename from data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.6__modify_columns_with_reserved_words.sql rename to data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql index bef1dc9532..342cacedff 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.6__modify_columns_with_reserved_words.sql +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql @@ -17,8 +17,8 @@ * under the License. */ -alter table definitions_nodes_metadata rename column key to metadata_key; -alter table definitions_nodes_metadata rename column value to metadata_value; -alter table definitions_metadata rename column key to metadata_key; -alter table definitions_metadata rename column value to metadata_value; +alter table definitions_nodes_metadata rename column key to name; +alter table definitions_nodes_metadata rename column value to meta_value; +alter table definitions_metadata rename column key to name; +alter table definitions_metadata rename column value to meta_value; alter table definitions_annotations rename column value to annotation; diff --git a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java index f6d330a5e5..cde1d5471a 100644 --- a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java +++ b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java @@ -35,16 +35,16 @@ @Entity @IdClass(CacheId.class) -@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "name", - "cache_key" }), indexes = @Index(columnList = "name,cache_key", unique = true)) +@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "cache_name", + "var_name" }), indexes = @Index(columnList = "cache_name,var_name", unique = true)) public class CacheEntity { @Id - @Column(nullable = false) + @Column(name = "cache_name", nullable = false) private String name; @Id - @Column(name = "cache_key", nullable = false) + @Column(name = "var_name", nullable = false) private String key; @Convert(converter = JsonBinaryConverter.class) diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql index cd0c1cc9bb..49b4397939 100644 --- a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql @@ -17,4 +17,5 @@ * under the License. */ -alter table kogito_data_cache alter column key rename to cache_key; +alter table kogito_data_cache alter column name rename to cache_name; +alter table kogito_data_cache alter column key rename to var_name; diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql b/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql index 76864ba25e..11f9fb8fda 100644 --- a/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql @@ -19,8 +19,8 @@ create table if not exists kogito_data_cache ( - cache_key varchar(255) not null, - name varchar(255) not null, + var_name varchar(255) not null, + cache_name varchar(255) not null, json_value jsonb, - primary key (cache_key, name) + primary key (var_name, cache_name) ); diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql b/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql index 4661a811b6..9c74443e8b 100644 --- a/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql @@ -17,4 +17,5 @@ * under the License. */ -alter table kogito_data_cache rename column key to cache_key; +alter table kogito_data_cache rename column name to cache_name; +alter table kogito_data_cache rename column key to var_name; diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java index ec78c81aec..8a93c264c7 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java @@ -49,9 +49,9 @@ class BasicTypeMappingIT { private static final String CACHE_NAME = "BasicType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " + - "name, " + - "cache_key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "field1MappedField, " + "field2MappedField " + "FROM " + @@ -174,8 +174,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = BasicTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "cache_key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "field1MappedField", column = "field1MappedField"), @FieldResult(name = "field2MappedField", column = "field2MappedField") }) }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java index 304cad0913..7bf4292c1f 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java @@ -50,9 +50,9 @@ class ComplexHierarchicalTypeMappingIT { private static final String CACHE_NAME = "ComplexHierarchicalType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " + - "name, " + - "cache_key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "root, " + "nestedBasicMappedField, " + "nestedComplexCollectionMappedField1, " + @@ -210,8 +210,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = ComplexHierarchicalTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "cache_key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "root", column = "root"), @FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"), @FieldResult(name = "nestedComplexCollectionMappedField1", column = "nestedComplexCollectionMappedField1"), diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java index 083f4b69cc..5ad3c00ae8 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java @@ -49,9 +49,9 @@ class HierarchicalTypeMappingIT { private static final String CACHE_NAME = "HierarchicalType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " + - "name, " + - "cache_key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "root, " + "nestedBasicMappedField, " + "nestedBasicCollectionMappedField " + @@ -194,8 +194,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = HierarchicalTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "cache_key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "root", column = "root"), @FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"), @FieldResult(name = "nestedBasicCollectionMappedField", column = "nestedBasicCollectionMappedField") }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java index e19a3c6318..38767dd53d 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java @@ -72,8 +72,8 @@ void dynamicMappingDefinitionCreation() { final PostgresMappingDefinition definition = new PostgresMappingDefinition("ExampleMappingId", "kogito_data_cache", "json_value", - List.of(new PostgresField("cache_key")), - List.of(new PostgresPartitionField("name", "Example")), + List.of(new PostgresField("var_name")), + List.of(new PostgresPartitionField("cache_name", "Example")), "Example", List.of(new PostgresMapping("field1", new PostgresJsonField("field1", JsonType.STRING)))); diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java index ea7f70c5d0..efb4ba5804 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java @@ -55,9 +55,9 @@ class PostgresApplyMappingSqlBuilderIT { private static final String CACHE_NAME = "DynamicType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " + - "name, " + - "cache_key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "field1MappedField, " + "field2MappedField " + "FROM " + @@ -89,8 +89,8 @@ void testApplyMappingToExistingData() { databaseManager.createArtifacts(new PostgresMappingDefinition("dynamicMappingId", "kogito_data_cache", "json_value", - List.of(new PostgresField("cache_key")), - List.of(new PostgresPartitionField("name", CACHE_NAME)), + List.of(new PostgresField("var_name")), + List.of(new PostgresPartitionField("cache_name", CACHE_NAME)), "DynamicTypeExtract", List.of(new PostgresMapping("field1", new PostgresJsonField("field1MappedField", JsonType.STRING)), @@ -120,8 +120,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = DynamicTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "cache_key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "field1MappedField", column = "field1MappedField"), @FieldResult(name = "field2MappedField", column = "field2MappedField") }) }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json index 5bb3dbe4dc..6a12a98333 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json @@ -6,12 +6,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "cache_key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "BasicType" } ], @@ -39,12 +39,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "cache_key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "HierarchicalType" } ], @@ -79,12 +79,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "cache_key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "ComplexHierarchicalType" } ],