You should probably look into using either a Maven profile or overriding the property on the command line (using -D).
I want to update my database using a changeLogFile from Maven (during build/integrationTest) and command line (manual update/delete the database). This is currently (Liquibase 2.0.3) not possible due to the attribute ‘relativeToChangeLogFile’ of the xml element sqlFile. I use a changeSet with sqlFile for initially populating the database. The problem is, if I use Maven, this attribute has to set to ‘false’ but for use from command line, it has to be ‘true’. My project has the default maven web app directory layout and the liquibase-changesets.xml and the import.sql referring from xml-element sqlFile are in src/main/resources. The pom.xml is in the project root along with the createDB.sh script. If that script contains the liquibase calls directly
- liquibase --defaultsFile=liquibase-postgresql.properties dropAll
- liquibase --defaultsFile=liquibase-postgresql.properties --changeLogFile=liquibase-postgresql-changelogs.xml update
then I must switch ‘relativeToChangeLogFile’ from false to true everytime I want to start the script from the command line. My workaround is a second script in src/main/resources containing the liquibase calls mentioned above and calling that script from /createDB.sh but … you know … remember the DRY principle from the pragmatic programmers. Is there any other solution ?
Thanks in advance