openmrs-core icon indicating copy to clipboard operation
openmrs-core copied to clipboard

TRUNK-6208: Upgrade 2.7 Platform to Liquibase 4.27.0

Open k4pran opened this issue 9 months ago • 19 comments

Description of what I changed

This upgrades liquibase to the latest version 4.27.0. There are few other changes worth mentioning

  • duplicateFileMode is a new config added to liquibase to handle duplicate changelogs. The only options at the minute is for it to error on any duplicates or do log a warning. I couldn't work around this config without overriding some of the lower level liquibase classes, so I opted to default it to WARN. The issue is that the warning logs are quite excessive. I raised this with liquibase and got the green light to add more options - https://github.com/liquibase/liquibase/issues/5856
  • I wasn't 100% sure the best way to add duplicateFileMode as a config in openmrs, it seems that liquibase needs it set in the pom, a liquibase.properties file or an environment variable. It also needs set before liquibase runs, I opted to add a constant defaults to WARN with the option to override this either in the openmrs-runtime.properties or in the environment variables with the openmrs properties taking precedence.
  • The liquibase changelogs after 2.4.x were missing the logicalFilePath attribute, this resulted in an issue where ChangeLogDetective had difficulty determining the changelog used to initialize the database. I only added the missing attribute in 2.6.x and later. I could also add it to 2.5.x but didn't want to cause a compatibility issue doing so.
  • The md5sum generator in liquibase changed to version 9 which isn't compatible with version 3 that was used to calculate checksums in the H2 database used by integration tests. I got liquibase to recalculate the checksums for the update.xml files so you will see the H2 db object in the diff.
  • A change was also made in liquibase to determine if a type is an int or bigint. An integer with a display width greater than 10 e.g. int(11) is considered a bigint, this broke some tests that used the retired_by column in the program_attribute_table as hibernate has it set as an integer rather than a long, I added a changeset to reduce it from int(11) to int(10) to fix this.

I updated a few deprecated methods, there are some additional deprecation that I didn't touch, I can do it here or separately in case it is more involved:

  • OpenmrsClassLoaderResourceAccessor - most of this has been deprecated
  • FileSystemResourceAccessor - has been deprecated in favour of DirectoryResourceAccessor or ZipResourceAccessor. I think FileSystemResourceAccessor was handling both cases.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-6208

Checklist: I completed these to help reviewers :)

  • [X] My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • [X] I have added tests to cover my changes. (If you refactored existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • [X] I ran mvn clean package right before creating this pull request and added all formatting changes to my commit.

    No? -> execute above command

  • [X] All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • [X] My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

k4pran avatar May 13 '24 15:05 k4pran