Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release process for MongoDB changes

When its RDBMS, I used Liquibase to deploy the changes in the target database. That has support for multi-tenancy & roll back to different versions.

In Mongo, I tried to find the equivalent library and found the below.

  1. https://github.com/mongobee/mongobee - Requires java skillset. Last update was 2 Years ago.
  2. https://github.com/coldze/mongol - Stick to just Json. Low reputation.
  3. https://github.com/mongeez/mongeez - Kind of promising but very outdated.
  4. https://github.com/tj/node-migrate - Done in jS, has reputation better than others, but lot of learning required to be familiar with this framework IMO.

For me the criteria are,

  1. Upgrade from one version to any new version must be possible.
  2. Downgrade from the current version to any old version must be possible ( should have the feasibility to do the complex migration. Ex, refer to the different collections and assign a computed value from the output.
  3. Must be able to extract the changes before execution. For verification purposes mostly. Otherwise, during new build deployment, the changes alone to be executed.
  4. Easy to adopt, so a lot of learning should be avoided.

You have some other working concept, eager to know. Thanks,

A.

like image 997
iDroid Avatar asked Jun 01 '20 14:06

iDroid


3 Answers

The mongodb extension for Liquibase just came out. Since you are familiar with Liquibase you might the extension. https://github.com/liquibase/liquibase-mongodb

like image 149
Mike Olivas Avatar answered Sep 24 '22 08:09

Mike Olivas


If you are using Java, a very good option(I'd say probably the best) is Mongock.

It provides everything you need and there are very good features in the road map.

To get started(if using Spring 5 and spring data 3), you just need :

  1. Add Mongock to your pom
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.github.cloudyrock.mongock</groupId>
            <artifactId>mongock-bom</artifactId>
            <version>4.1.17</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<!-- ... -->
<dependency>
    <groupId>com.github.cloudyrock.mongock</groupId>
    <artifactId>mongock-spring-v5</artifactId>
</dependency>

<dependency>
    <groupId>com.github.cloudyrock.mongock</groupId>
    <artifactId>mongodb-springdata-v3-driver</artifactId>
</dependency>
  1. Add your Spring and MongoDB dependencies to your pom
  2. Add minimum configuration
mongock:
  change-logs-scan-package:
    - your.package.for.changelogs
  1. Create your changeLog in the package indicated previously indicated: your.package.for.changelogs
@ChangeLog(order = "001")
public class DatabaseChangelog {
  
  @ChangeSet(order = "001", id = "changeWithoutArgs", author = "mongock")
  public void yourChangeSet() {
   // your migration here
  }
}
  1. Add Mongock annotation to your SpringBoot application
@EnableMongock
@SpringBootApplication
public class App {
  public static void main(String[] args) {
    new SpringApplicationBuilder().sources(App.class).run(args);
  }
}

This is only a quick introduction on how it works. Please a look to the documentation for more information.

Disclosure: I am one of the Mongock authors.

like image 39
Mongock team Avatar answered Sep 23 '22 08:09

Mongock team


There is this one - mongock.io which is similar like how Liquibase work and works perfectly. Below is the github URL: https://github.com/cloudyrock/mongock

like image 26
Yazik Avatar answered Sep 21 '22 08:09

Yazik