Tuesday, 24 January 2012

Generating Liquibase change set from the differences of two Two database Instances

One of the easiest way to generate the Liquibase Changeset is to keep the two sets of database instances and update one instance with the required changes and generate the changeset using the following command


liqubase.bat --driver=oracle.jdbc.OracleDriver \
        --url=jdbc:oracle:thin:@testdb:1521:test \
        --username=bob \
        --password=bob \
    diffChangeLog \
        --referenceUrl=jdbc:oracle:thin:@localhost/XE \
        --referenceUsername=bob \
        --referencePassword=bob


Writing such a long command could be error prone and if you create a batch file(or shell script) that could be used only for diffChangeLog, if you want to see just the diff then you have to write one more batch file, in the same way for every liquibase command (parameterised batch also could not work well for all possible command options).

Alternatively you can just create liquibase.properties file in the liquibase root folder as in the below example


changeLogFile = changeset.xml
url = jdbc:postgresql://localhost:5432/instance1
username = username1
password = password1
referenceUrl = jdbc:postgresql://localhost:5432/instance2
referenceUsername = username2
referencePassword = password2
driver = org.postgresql.Driver



Once created this file, you can simply execute the commands like

liquibase diff
liquibase diffChangeLog
etc

with out passing any parameter. Liquibase will use the liquibase.properties file for the parameters. 


2 comments:

  1. where i can search for this liquibase.properties file in my linux system...?????

    ReplyDelete
    Replies
    1. find . -name liquibase.properties -print

      Delete