Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegrationSpringBoot: Autoconfiguration missing new duplicateFileMode and searchPath #3230

Open
chuber50 opened this issue Sep 1, 2022 · 8 comments

Comments

@chuber50
Copy link

chuber50 commented Sep 1, 2022

Environment

Liquibase Version: 4.15.0

Liquibase Integration & Version: Spring Boot

Liquibase Extension(s) & Version:

Database Vendor & Version: MariaDB latest

Operating System Type & Version: Windows, Java 11

Infrastructure Type/Provider: VM

Description

Spring Boot integration Liquibase Autoconfiguration does not yet support the new properties duplicateFileMode and searchPath

Steps To Reproduce

Actual Behavior

Configuration properties are not available

Expected/Desired Behavior

Configuration properties should be available

@malteesch
Copy link

I stumbled upon the same issue whlle trying to configure the searchPath with Spring Boot.
Are there plans to add those configuration options?
I'd be happy to help with the implementation.

@nvoxland
Copy link
Contributor

In the liquibase code, there is a liquibase.configuration.LiquibaseConfiguration system that is modeled after the spring boot cascading configuration system. That system gets populated by pluggable liquibase.configuration.ConfigurationValueProvider implementations.

We have that because the number of configuration options available will continue to expand over time and we don't want to require all the integrations to keep up with them. Plus, since we support extensions that add behavior which may define their own configuration values, you really can't even know what configuration options ARE available.

I've not looked at the spring boot integration code enough to remember off hand how easy that will be to set up. But, you should be able to make a SpringBootConfigurationValueProvider that implements the interface as a wrapper for spring boot's configuration system. That way, when the liquibase code asks for liquibase.duplicateFileMode or liquibase.searchPath the SpringBootConfigurationValueProvider will return back "I have that configured in spring.liquibase.duplicateFileMode, here's the value" without the spring boot integration needing to even know that is a value that will be looked for.

But: one question I have is whether there is an validation of possible values coded into the spring boot integration? Does that code need to know what the possible configuration values are? Does that have to be a static list known at compile time? Or can it be built up at runtime from the metadata available in LiquibaseConfiguration?

@malteesch
Copy link

Thanks for the quick response!
I'm going to try that out.

@benze
Copy link

benze commented Aug 21, 2023

@malteesch Were you able to resolve your issue? Any chance you have the Config Value Provider handy that I can reuse?

@malteesch
Copy link

@benze I actually ended up not needing it.
So, unfortunately I don't have anything that I could provide to you, sorry.

If I remember correctly it was a config mistake on my end which lead to the changelog files not being found.
And then I tried to manually set the searchPath, which lead me to this issue.
Reviewing my config and/or upgrading to the latest version resolved the issue for me.

Best of luck in resolving your issue!!

@tiarebalbi
Copy link

This still something we should consider... In this example I'm getting a failure due to a duplicated file but it isn't....

Caused by: java.io.IOException: Found 2 files with the path 'classpath:/db/changelog/db.changelog-master.yaml':
    - file:/Users/....../genly-design/build/resources/main/db/changelog/db.changelog-master.yaml
    - jar:file:/Users/....../genly-design/build/libs/genly-design-0.0.1-SNAPSHOT.jar!/db/changelog/db.changelog-master.yaml
  Search Path: 
    - Spring classpath
  You can limit the search path to remove duplicates with the liquibase.searchPath setting. Or, if you KNOW these are the exact same file you can set liquibase.duplicateFileMode=WARN.
	at liquibase.resource.ResourceAccessor.get(ResourceAccessor.java:195) ~[liquibase-core-4.20.0.jar:na]
	at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:29) ~[liquibase-core-4.20.0.jar:na]
	... 41 common frames omitted

Liquibase is finding the change log file from the jar and from the classpath.

@tiarebalbi
Copy link

for now here's my workaround:

db.changelog-master.yml

databaseChangeLog:
  - include:
      file: file:./<MY FOLDER>/src/main/resources/db/changelog/db.changelog-security.yaml
      relativeToChangelogFile: false

@SoboAv
Copy link

SoboAv commented Oct 16, 2023

We have that because the number of configuration options available will continue to expand over time and we don't want to require all the integrations to keep up with them. Plus, since we support extensions that add behavior which may define their own configuration values, you really can't even know what configuration options ARE available.

Such parameters should be set from spring.liquibase.parameters.*
e.g.

spring:
  liquibase:
    parameters:
      duplicate-file-mode: WARN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Open Issues
Development

No branches or pull requests

7 participants