Giter Site home page Giter Site logo

mongo-migrate's Introduction

mongo-migrate

mongo-migrate Maven plugin provides goals to perform mongo DB migrations.

Pre-Alpha

I wanted to try my hand at writing maven plugin to support some of my various mongo hack-fun-projects. So, please note that mongo-migrate is incredibly raw and pre-alpha. Any and all feedback is welcome.

Installation

Commandline:

$ git clone https://github.com/wmluke/mongo-migrate.git
$ cd mongo-migrate
$ mvn install

Project POM:

<project>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>net.bunselmeyer</groupId>
            <artifactId>mongo-migrate</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>
        ...
    </dependencies>

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>net.bunselmeyer</groupId>
                <artifactId>mongo-maven-plugin</artifactId>
                <version>0.1-SNAPSHOT</version>
                <configuration>
                    <!-- Package to find Migrations -->
                    <package>com.foo.migrations</package>
                </configuration>
            </plugin>
            ...
        </plugins>
    </build>
</project>

Java Usage

@Connection

  • host: (Optional) Mongo DB host. Defaults to "localhost"
  • db: Mongo database name.
  • version: Migration version as an ISO timestamp.

Migration

Abstract class used to define migrations.

Example

@Connection(db = "blog", version = "2012-09-11T00:14:00-0800")
public class RenameUserEmailFieldMigration extends Migration {

    @Override
    public void up(DB db) {
        renameField(db, "User", "emailAddress", "email");
    }

    @Override
    public void down(DB db) {
        renameField(db, "User", "email", "emailAddress");
    }
}

Maven Goals

mongo:migrate

Migrate a mongo DB upwards. This goal will create a collection called MigrationVersionDetails that contains...

{
    "_id": ObjectId( "505d6c18c2202768f668d4eb" ),
    "version" : 1347351240000,
    "migrationName" : "com.foo.migrations.RenameUserEmailFieldMigration",
    "run" : 1348299800474
}
$ mvn mongo:migrate

mongo-migrate's People

Contributors

wmluke avatar

Stargazers

Gabriel Rubens avatar Vitalii avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

pnayak sfchao

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.