changelog filename in database contains full OS path?

Hi,
I am having hard time configuring Liquibase in current project. The problem is that each time I switch from one dev machine to another, Liquibase goes crazy and tries to reapply all the changelogs.

The problem is the databasechangelog table contains FULL OS path, from machine that was used to run the changelog, like:
/home/witoldsz/projects/sgn/sgn-parent/sgn-db/src/main/resources/sgn-core/db/db.changelog.001.xml
 
I cannot remember having such issues in previous project. The difference is that previously, the Liquibase was launched by an application, in current project it is launched by maven plugin.

Is it a bug?

Thanks,
Witold Szczerba

P.S.I have came across many threads about the pain related to filenames in databasechangelog table (including my case) and I cannot get the reason behind it. There is ID and an author. It is not that hard for authors to keep track of the IDs they use. In my project we use a pattern: year-month-day-seq, where seq is a sequence number in that day per author. Impossible to create two identical ID by mistake, but let’s assume author created duplicated ID: Liquibase could throw an exception (duplicated ID detected), author would correct the ID and problem solved.
I would strongly advise to reconsider the filename in changelogs. They cause lots of troubles.

P.P.S
This is my first post here, I would like to thank the authors and contributors for making such a great tool!

Unless I’m missing the essence of your problem, the simple solution is to put logicalFilePath=“db.changelog.001” either in your <databaseChangeLog or <changeSet tags

The reason it is storing the absolute paths is probably because you are referencing it or the root changelog absolutely. The best way to run liquibase is to have your changelog files in your classpath and then reference the all changelogs as classpath-relative. That way you can change where the files actually are across servers and across time and everything will still work.


Nathan

Yes, you can add it to http://liquibase.jira.com.


Thanks,

Nathan

Hmm, you are right, this is how it is configured in Maven’s pom.xml, attaching for reference.
Is it possible to reference the location of changelog classpath relative?

By the way: I cannot move the Liquibase process to application startup, because I need migration to happen before compilation of my main application (JOOQ generates classes required to compile the app).

  1.      
  2.         org.liquibase
  3.         liquibase-maven-plugin
  4.         2.0.5
  5.        
  6.          
  7.             sgn-db
  8.             process-resources
  9.            
  10.               update
  11.            
  12.            
  13.               ${project.basedir}/src/main/resources/sgn-core/db/db.changelog.xml
  14.               ${sgn.db.driver}
  15.               ${sgn.db.url}
  16.               ${sgn.db.user}
  17.               ${sgn.db.pass}
  18.               false
  19.            
  20.          
  21.        
  22.      

Hi,
I cannot run Liquibase after compilation, because my project won’t compile because of missing classes.
It goes like this:

  1. sgn-db mvn project:
    1. Liquibase upgrades (or creates) database,
    2. JOOQ generates classes,
  2. sgn mvn project depends on sgn-db,
    1. compiles code using classes generated in step #1.2
    2. sgn mvn starts unit and database integration tests,
  3. sgn gets deployed

So, it looks like there is no way I can resolve the issue other than following pmendelson workaround. One possible solution would be to allow setting a base path in configuration somewhere, so all the files would be located and identified starting from that path. Additionally it would be nice if there would be an option to get rid of the file names in changelogs all together.

Should I report this in some issue tracking system?

Thanks,
Witold Szczerba

Hi,
I was just asking if this is a bug, because it seems like it is.

Setting logicalFilePath is a nice workaround for the problem, though it needs to be used in every single file. If one forgets to apply it in a new file, the changelog table will suffer and need manual recovery.

Regards,
Witold Szczerba

Now hear this: the problem I am facing was already resolved and described in manual. I have just missed it:
http://www.liquibase.org/manual/maven

Paths to files

As of version 1.6.1.0 of the Maven plugin all files are resolved from the maven test classpath for the Maven project or an absolute path. This allows for DatabaseChangeLogs to be present in other Maven artifacts (on the classpath) and able to be used to invoke liquibase on a database.

 
So all I had to do was to get rid of ${project.basedir}/src/main/resources/, see the diff:
  1. -  ${project.basedir}/src/main/resources/sgn-core/db/db.changelog.xml
  2. + sgn-core/db/db.changelog.xml

Regards,
Witold Szczerba

I’m not a big maven guy, but it looks like the Maven plugin just uses the maven project classpath as the classpath to search. If you have to run liquibase before the compilation phase, that won’t be available yet.


You can’t run JOOQL after the compliation, or configure maven to run liquibase before JOOQL within compilation?

You can subclass the liquibase maven classes and override the getFileOpener() method, but I’m not sure how easy that is to integrate into maven.


Nathan

Seems like the best place to discuss would be with the gradle plugin developers. There are only 3 people that have contributed to it. The main person seems to be Steve Saliman. https://github.com/stevesaliman

Here is the github link for the plugin project: https://github.com/liquibase/liquibase-gradle-plugin

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

I know this is an old thread however, I am having the same issue using the Gradle plugin. It seems to behave differently depending on if I run the script from the parent project or within the sub-project. If I run it inside the subproject, it uses an absolute path. If I run from the parent project, it uses the shorter path (like “src/db/main/changelogs/changelogxyz.sql”).

This seems to cause a ton of grief for people including myself. I wished it was as simple as absolutePath=“true”/“false”