days
-6
-8
hours
-1
-3
minutes
0
-8
seconds
-5
-7
search
Put up your feet and migrate your data

Java framework Liquicouch makes schema changes comfortable and easy

Sarah Schlothauer
liquicouch
© Shutterstock / Javier Brosch

Looking for a new Java framework to help you manage your Couchbase? Look no further than Liquicouch. It’s time to favor simplicity when migrating data!

Relax, get comfy, lay down, and let someone else take over – or at least, make things a little easier for you!

Liquicouch is a liquibase-like framework that automates schema changes for you. Pull up a seat, let’s have a look.

Migrate your schema with Liquicouch

Released on July 30th, 2018, Liquicouch takes inspiration from the database refactoring tool liquibase. It is a data migration tool for Java, Scala, and Kotlin for Couchbase. Supported by Denis Rosa, a developer advocate for Couchbase, it is ready for usage. Above all, the main goal of it is to keep things simple and comfortable to use.

Migrating old database schema to a new schema can be a struggle and a lot can easily go wrong and cause an entire system failure. That’s where LiquiCouch comes into play.

From GitHub: “LiquiCouch is a Java framework which helps you to manage changes in your Couchbase and synchronize them with your application. The concept is very similar to other db migration tools such as Liquibase or Flyway but without using XML/JSON/YML files. LiquiCouch provides new approach for adding changes (change sets) based on Java classes and methods with appropriate annotations.”

SEE ALSO: The rise of Ballerina: An important piece of the microservices architecture puzzle

Ready, set, let’s start!

Ready to hop on board?

All you need is either Maven or Gradle and you’ll be ready to use this framework in no time.

For Maven:

<dependency>
<groupId>com.github.deniswsrosa</groupId>
<artifactId>liquicouch</artifactId>
<version>0.6.4</version>
</dependency>

For Gradle:

compile 'org.javassist:javassist:3.18.2-GA' // workaround for ${javassist.version} placeholder issue*
compile 'com.github.liquicouch:liquicouch:0.6.4'

Whether or not you use Spring or not, you are still in luck because it is usable either with or without Spring. (For more information on how to insatantiate Liquicouch as a singleton bean, follow the given instructions on GitHub.)

Annotation parameters

Before you start, have a look at some of the included annotation parameters and what each one does:

order – a string for sorting change sets in one changelog. It sorts alphabetically in an ascending order. It can be a number, a date etc.

id – a name of a change set that must be unique for all change logs in a database

author – the author of a changeSet

runAlways – [optional, default: false] changeset will always be executed but only the first execution event will be stored as a document.

recounts – [optional, default: 0] [Only applied when changSet returns a ParameterizedN1qlQuery] if you want to be sure that all documents have been updated, you can return a ParameterizedN1qlQuery. This query expects a result called size. If size is not zero, the query will be executed again according to the number of recounts specified. If none of the recounts returns zero, an exception will be thrown, and the application will fail to start.

retries – [optional, default: 0] [Only applied when changSet returns a ParameterizedN1qlQuery] if the recount operation fails (the count result isn’t zero), it will rerun the changeSet in an attempt to update the remaining documents (Your changeSet should be able to run multiple times without any side effects). If all retries fail, an exception will the thrown and the application will fail to start.

SEE ALSO: TypeScript 3.0: Get to know the unknown type

Check it out on GitHub and get started by cloning the sample project demo.

Since Liquicouch is so new, you can contact its creator with questions and concerns on twitter @deniswsrosa.

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University in Long Branch, New Jersey and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.