Schema creation fails when schema-initialized index is already created but vertex... 84/141184/1 master
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 11 Jun 2025 07:44:13 +0000 (09:44 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 11 Jun 2025 07:44:13 +0000 (09:44 +0200)
- do not attempt to create schema-initialized index when it already exists

Issue-ID: AAI-4177
Change-Id: I95f25b767ba03986d8290125b97c35abca756b80
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
src/main/java/org/onap/aai/schema/GenTester.java

index cf82d19..70be7ef 100644 (file)
@@ -236,6 +236,11 @@ public class GenTester {
 
        private static void createSchemaInitializedIndex(JanusGraph graph, JanusGraphManagement mgmt) throws InterruptedException {
                // creating a composite index
+               boolean indexExists = mgmt.containsGraphIndex(SCHEMA_INITIALIZED);
+               if(indexExists) {
+                       LOGGER.debug(SCHEMA_INITIALIZED + " index already exists. Skipping creation.");
+                       return;
+               }
                LOGGER.debug("-- Building an index on property schema-initialized");
                PropertyKey schemaInitialized = mgmt.makePropertyKey(SCHEMA_INITIALIZED).dataType(Boolean.class).make();
                mgmt.buildIndex(SCHEMA_INITIALIZED, Vertex.class)