Giter Site home page Giter Site logo

martenm / migrationm Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 36 KB

A very simple but robust migration manager that allows developers to easily update the databases that they use in a project without having to depend on weird code.

Java 100.00%
java migrations migration maven

migrationm's Introduction

MigrationM

A simple migration manager for Java applications.

โญ Features

  • Makes updating a database easy.
  • Pure .sql files (or any other extension)
  • Don't bother users with executing queries manually
  • Simple way to store migrations in the resource folder
  • (Possible) support for different databases

๐Ÿ“ƒ Description

Exporting programs to users is fun, but when a database needs changes it often becomes quite a pain. This is especially true for SQL languages.

MigrationM offers a simple and easy to use migration system that makes changing the database easy. By applying migration files the database can be build from the ground up or updated when required.

Migrations can be stored as simple files in the resource folder. MigrationM provides an easy way to load these files.

Using a custom DataBaseManager it's also easy to support other languages than SQL.

โš™ Usage

An example project has been provided in the MigrationM-Example folder. A basic rundown can be read here.

1. Create the migrations

Create a folder in your resource folder. For this example we will use the folder name migrations.

After creating the folder create your migrations and put them into the folder. The name of the migrations HAS to be the following format: yyyy-m-d-hh.mm-description.extension. The -description part is not required but recommended.

2. Add the maven dependencies to your project

Base module required for basic functionalities:

<dependency>
    <groupId>nl.martenm</groupId>
    <artifactId>MigrationM-Base</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

Different databases might require different DataBaseManagers. That's why these are seperate submodules. For MySql the following module has been tested.

<dependency>
    <groupId>nl.martenm</groupId>
    <artifactId>MigrationM-SQL</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

3. Add the MigrationM manager to the startup of your program

Add the MigrationM manager to the startup of your program. In order to load the migrations in the migrations folder simply call the method .loadMigrations(folder, RootClass.class). After that you can simply call .migrate() and the migrations will execute automatically.

migrationManager = new MigrationM(
                new ProgramInfo("Name", "1.0.0", logger),
                new SQLDatabaseManager(dataSource));

migrationManager.loadMigrations("migrations", ExamplePlugin.class);
boolean success = migrationManager.migrate();

4. Have a party ๐ŸŽ‰

Have a party, you don't have to worry about writing confusing code in order to update your database. While you are partying, don't forget to โญ this repository.

๐Ÿ“Ž Maven repository

Currently there is no central public repository for this project. You can clone the project your self and install the MigrationM-Base and MigrationM-SQL by running the mvn clean install command.

โ“ FAQ

I already have an existing project and I want to include this!

That's great! When writing queries for the first migration do keep in mind that there might already exist a table (e.g. users of previous versions).

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.