Maven plugin for MongoDB migrations (uses Mongeez)
-
Add build plugin dependency to your POM
<build> <plugins> <plugin> <groupId>pl.coderion.mongodb</groupId> <artifactId>mongeez-maven-plugin</artifactId> <version>0.9.4</version> <configuration> <dbName>test</dbName> <changeLogFile>src/main/mongeez/mongeez.xml</changeLogFile> </configuration> </plugin> </plugins> </build>
-
Run maven goal:
mvn mongeez:update
-
<configuration> <dbUri>mongodb://mongodb0.example.com:27017/admin</dbUri> <dbHostName>foo.bar.com</dbHostName> <dbPort>27017</dbPort> <dbName>test</dbName> <dbAuth>true</dbAuth> <username>foo</username> <password>bar</password> <changeLogFile>src/main/mongeez/mongeez.xml</changeLogFile> </configuration>
dbHostName and dbPort are ignored when dbUri is defined
-
Create mongeez.xml with all change logs. See how to use mongeez.
Example changelog file:
<?xml version="1.0" encoding="UTF-8"?> <mongoChangeLog> <changeSet changeId="1st change" author="coderion"> <script> db.foo.createIndex({"foo": 1}); </script> </changeSet> <changeSet changeId="2nd change" author="coderion"> <script> db.foo.update({"foo": "bar"}, { $set: {"some": "any" } }, { multi: true }); </script> </changeSet> </mongoChangeLog>
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0