Skip to content

Commit

Permalink
Update cygnus-common/src/main/java/com/telefonica/iot/cygnus/backends…
Browse files Browse the repository at this point in the history
…/mongo/MongoBackendImpl.java

Co-authored-by: Fermín Galán Márquez <[email protected]>
  • Loading branch information
AlvaroVega and fgalan authored Oct 17, 2023
1 parent ec0e2d1 commit bb6b316
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ public void createIndex(MongoDatabase db, String collectionName, BasicDBObject k
try {
db.getCollection(collectionName).createIndex(keys, options);
} catch(Exception e) {
// Our guess is:
// IndexOptionsConflict -> when the same index (name and keys) already exits
// IndexKeySpecsConflict -> when an index with the same name but different keys (i.e. DM was changed) already exist
if (e.getMessage().contains("IndexOptionsConflict") ||
e.getMessage().contains("IndexKeySpecsConflict")) {
db.getCollection(collectionName).dropIndex(options.getName());
Expand Down

0 comments on commit bb6b316

Please sign in to comment.