diff --git a/src/main/java/org/mongeez/dao/MongeezDao.java b/src/main/java/org/mongeez/dao/MongeezDao.java index 51d733c..391c5b7 100644 --- a/src/main/java/org/mongeez/dao/MongeezDao.java +++ b/src/main/java/org/mongeez/dao/MongeezDao.java @@ -46,6 +46,7 @@ public MongeezDao(Mongo mongo, String databaseName, MongoAuth auth) { private void configure() { addTypeToUntypedRecords(); loadConfigurationRecord(); + dropObsoleteChangeSetExecutionIndices(); ensureChangeSetExecutionIndex(); } @@ -84,9 +85,22 @@ private void loadConfigurationRecord() { } } + /** + * Removes indices that were generated by versions before 0.9.3, since they're not supported by MongoDB 2.4+ + */ + private void dropObsoleteChangeSetExecutionIndices() { + String indexName = "type_changeSetExecution_file_1_changeId_1_author_1_resourcePath_1"; + DBCollection collection = getMongeezCollection(); + for (DBObject dbObject : collection.getIndexInfo()) { + if (indexName.equals(dbObject.get("name"))) { + collection.dropIndex(indexName); + } + } + } + private void ensureChangeSetExecutionIndex() { BasicDBObject keys = new BasicDBObject(); - keys.append("type", RecordType.changeSetExecution.name()); + keys.append("type", 1); for (ChangeSetAttribute attribute : changeSetAttributes) { keys.append(attribute.name(), 1); }