Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #25 from davidmc24/2.4-compatibility

MongeezDao: add support for MongoDB 2.4
  • Loading branch information...
commit 219b7a5909b15849ffe9c84bed9dfa4eba48906a 2 parents 01128b8 + 77f199b
@epishkin epishkin authored
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/main/java/org/mongeez/dao/MongeezDao.java
View
16 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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.