Problem with dependency between projects

Hello,

Where I work, we develop many frameworks and some applications that make use of these frameworks. Each of these frameworks has its own entities, thus the application that making use of them, will have to create all database tables for them.

Recently, we started using Liquibase to automate and simplify the process of creating the database for an application. This is specially useful for the developers, that need to create the entire database on their machines when developing and testing an application.

Each of the frameworks has a changelog with the required tables, and the main application has a changelog that includes each of the required framework’s changelog XML.

With this model, the developer can easily create the application database running liquibase update only for the application’s changelog.

Everything was fine, but then I’ve stumbled into the following situation:

Suppose three frameworks and an application with the following changelogs:

  • Framework A: changelog_A.xml (creates some tables)
  • Framework B: changelog_B.xml (creates some other tables and includes changelog_A.xml.
  • Framework C: changelog_C.xml (creates some other tables and also includes changelog_A.xml.
  • Application: changelog_application.xml (creates some other tables and also includes chagenlog_B.xml AND changelog_C.xml

My problem happens if I run liquibase update for changelog_application.xml. Liquibase will see changelog_A.xml two times and will give me an error complaining of repeated changesets.

Don’t you think this is scenario that liquibase should handle? Can you suggest a better practice for this situation?

It is something liquibase should handle, but detecting duplicate changelogs in the import command has not yet been implemented.  If you wanted to look at the include code to see if you could solve it, that would be great, otherwise it is something we can look at for the 2.1 release. 

Beyond that, I think the best option currently would be to not have the different sub-changelogs refer directly to the changelogs they depend on, but rather run it from the master changelog.  It would be worth adding a changeSetRan precondition in changelog_B.xml to document and enforce that changelog_A had already ran, but don’t include it directly.

Nathan 

Thank you very much for the quick answer Nathan (although I just read it today  :stuck_out_tongue: ) !

If I manage to get some spare time I’ll try to take a look at the code.