0
votes

I am new to both Liquibase and Flyway. Was trying to do some Hello Worlds. I successfully ran basic SQL ( create insert etc ) using both Liquibase and Flyway. Was interested in running them from command line.

Flyway :

  • was kind of easy to start with
  • I had to just Put sql file in correct naming format 'V1_xxxx.sql' in correct folder 'flyway/sql' & Run 'flyway migrate'
  • the best part was it automatically picked up any new sql file given the correct file name.

LiquiBase :

  • had to spend some time to understand and use it
  • Need to give correct file name each time

    liquibase --driver=com.mysql.jdbc.Driver --classpath=/path/to/classes --changeLogFile=com/example/db.changelog1.xml --url="jdbc:mysql://localhost/example" --username=dev migrate

    liquibase --driver=com.mysql.jdbc.Driver --classpath=/path/to/classes --changeLogFile=com/example/db.changelog2.xml --url="jdbc:mysql://localhost/example" --username=dev migrate

Is there a way in liquibase to automatically pick the new xml files ? like Flyway i could just give folder name and Liquibase could use its table DATABASECHANGELOG to find the deltas and execute same.

Second Question for Liquibase only

In windows in order to run command successfully i had to change the changeLogFile parameter ... from ...

liquibase --driver=com.mysql.jdbc.Driver --classpath=/path/to/classes --changeLogFile=com/example/db.changelog1.xml      --url="jdbc:mysql://localhost/example" --username=dev migrate

to

liquibase --driver=com.mysql.jdbc.Driver --classpath=/path/to/classes --changeLogFile=./db.changelog1.xml      --url="jdbc:mysql://localhost/example" --username=dev migrate

i.e. i changed my present working directory to com/example and then modified the changeLogFile param to point to a file in current folder and execute command.

Is there a way i can point to changeLogFile in another folder (apart from current folder)

1

1 Answers

0
votes

One thing you can do to make liquibase a bit easier to use from the commandline is to create a file named liquibase.properties and save that in the directory where you are running the command. If I remember correctly, the command line will look for files with that name and use the properties in that file rather than requiring all the options on the command line. See http://www.liquibase.org/documentation/liquibase.properties.html and http://www.liquibase.org/documentation/command_line.html#using_a_liquibase.properties_file for more details. The docs there have this:

If you do not want to always specify options on the command line, you can create a properties file that contains default values. By default, Liquibase will look for a file called “liquibase.properties” in the current working directory, but you can specify an alternate location with the --defaultsFile flag. If you have specified an option in a properties file and specify the same option on the command line, the value on the command line will override the properties file value.

Yes, you can have liquibase automatically load files from a directory. You have to have a simple changelog.xml that is referenced from the command line or your properties file, but then that changelog can just reference another directory that contains more changelog files. The <includeAll> tag is used for this purpose (see http://www.liquibase.org/documentation/includeall.html) for more details.

Also, yes, you can put the changelog file wherever you like.