What is Liquibase ? – tutorial from scratch

 

Liquibase http://www.liquibase.org/ is a great open source tool database-independent for tracking, managing and applying schema changes. All changes to the database are stored in xml-files, each changeSet is identified by a combination "id" and "author" tag as well as the name of the file itself. A list of all applied changes is stored in each database which is consulted on all database updates to determine what new changes need to be applied. As a result, there is no database version number but this approach allows it to work in environments with multiple developers and code branches.

 

! ! !  Automatically creates DatabaseChangeLog Table and DatabaseChangeLogLock Table when you first execute a changeLog File. ! ! ! 

 

What we shoud have:

0. JDK 7

1. Java IDE – Eclipse/IDEA etc.

2. Maven

3. Example project

 

 

Screenshot at 11-39-21 Screenshot at 11-37-44

now i have created an empty Maven project. Now i have to configure pom.xml file- the source code is on github repository: https://github.com/TomaszWaszczyk/liquibase-tutorial-quickstart

 

We should remember that Liquibase is able to create first changelog file, how i have done it:

Screenshot at 16-07-42

 

now in the project's directory we run the following commands: (it depends on what we want to do)

 

[c]
clean compile db:create
clean compile db:schema
clean compile db:update
clean compile liquibase:update -Dliquibase.contexts=dev
clean compile liquibase:dropAll liquibase:update -Dliquibase.contexts=dev
[/c]

 

In this we have configured Liquibase, now in order to change a database we can create new so called changeSet and run update command. Full repository with source code you can find here: https://github.com/TomaszWaszczyk/liquibase-tutorial-quickstart

You may also like

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *