Giter VIP home page Giter VIP logo

mongration's Introduction

CircleCI Codacy Badge codecov Maven Central Licence

Mongration

MongoDB data migration tool for Spring Boot projects

Key features

  • Support Spring Boot lifecycle
  • Changelogs are regular spring beans
  • Support MongoDB transactions
  • Support ReactiveMongoTemplate

Getting started

Add a dependency

Maven

<dependency>
  <groupId>com.github.kuliginstepan</groupId>
  <artifactId>mongration</artifactId>
  <version>version</version>
</dependency>

Gradle

compile("com.github.kuliginstepan:mongration:version")

or

implementation 'com.github.kuliginstepan:mongration:version'

Configuration properties

  • mongration.enabled – enable or disable mongration. Default to true
  • mongration.changelogs-collection – collection for saving changesets. Defaults to mongration_changelogs
  • mongration.mode – mode for executing changesets. Defaults to AUTO, means that mongration will try to analyze changesets to choose proper mode. Possible modes are IMPERATIVE, REACTIVE

Changelog

To mark class as a changelog you need to annotate it with @Changelog. This annotation makes class regular spring bean. @Changelog has property id, which is a simple class name by default.

Changeset

To mark method as a changeset you need to annotate it with @Changeset. By default changeset's id is a method name. Changelog collection has compound unique index @CompoundIndex(def = "{'changeset': 1, 'changelog': 1}", unique = true) to check if changeset executed or not.

You can inject all beans available in bean factory as a changeset's method arguments.

Imperative changeset method must have void return type and reactive changeset method must returns Mono<Void>.

If you configured MongoDB and Spring to enable transaction support, changesets may be executed in transactions.

Indexes

Spring Mongo Data 2.2 provides a way to disable automation indexes creation. It's recommended to set spring.data.mongodb.auto-index-creation to false. Mongration creates indexes for all persistent entities after execution changesets.

Spring Boot Actuator

Mongration provides actuator endpoint mongration, which lists all executed changesets.

Migration from old versions

  • drop changelog table
  • remove all executed changesets

mongration's People

Contributors

evgenii-orel avatar kuliginstepan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.