4
votes

I have a Java Maven project. I'm using liquibase to update DB.

Locally, to update my db, I just run in command line:

mvn liquibase:update

In production environment, I don't have Maven installed.

What I need to achieve is through console, execute a command to run the liquibase scripts in a specific classpath.

Any ideas?

Edit:

Ok.I'm trying to follow this approach. I put in a folder the following items:

  1. liquibase jar

  2. The war containing my application and the liquibase changesets

  3. liquibase.properties: It contains the following:

    url=jdbc:jtds:sqlserver://xxxxxxxx:xxxx/xxxxx

    username=xxx

    password=xxxxx

    classpath=war_file.war

    changeLogFile=WEB-INF/classes/sql/projectName/liquibase/liquibase.xml

Then, in a console, I execute:

java -jar liquibase-core-3.0.5.jar update

It works! It finds my liquibase.xml file and starts the liquibase update.

BUT, when it refers to liquibase.xml that are inside another jar file included in the lib, it fails, because I included it in the liquibase.xml as:

<include file="../other_module/src/main/resources/sql/projectName/liquibase/liquibase.xml" />

How can I add this "include" without doing "src/main/resources" and make it find this xml?

1
What do you mean by "in a specific classpath"? What's the problem when you run liquibase on command line? - Jens
@Jens the thing is I need to execute the update directly in the production machine, which does not have Maven (and we don't want to install it). So I could not find what is the correctr procedure to update the prod db. - Adri
@Adri You have substantially changed the question from what was originally proposed. This is a new question on how to run the command-line client. The problem is a combination of your classpath and the file system path you are using within the liquibase file. Referencing a path that does not exist at run-time.... Check the files within your war file. You'll observe there is no file matching "../other_module/src/main/resources/sql/projectName/liquibase/liquibase.xml" - Mark O'Connor
Thanks! It works now. Thanks all for the support. - Adri

1 Answers

3
votes

Running the updateSQL goal on your Dev machine:

mvn liquibase:updateSQL

You can generate a migration script:

└── target
    └── liquibase
        └── migrate.sql

This is one of my favourite features of liquibase. Sometimes clients insist that all database schema changes must be performed manually by their staff.

Another option is to build an auto-upgrade capability into your application. See the servlet listener