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

Not supporting @ConditionalOnExpression or @ConditionalOnProperty #644

Open
davidvuletas opened this issue Oct 13, 2023 · 2 comments
Open

Comments

@davidvuletas
Copy link

Description

I'm trying to have the execution of the change unit only by some conditions, similar as how we have @Profile to execute something for specific Spring profile only. I'm trying to use @ConditionalOnExpression annotation, but it seems that it is ignoring that annotation at all, and Change Unit would be always executed.

PRIORITY

[NORMAL]

Version and environment

Mongock + Environment

  • mongock-spring-boot-5.4.3
  • springboot-starter-parent-2.4.3
  • mongodb-springdata-v3-driver-5.4.3
  • Autoconfiguration way of using Mongock

Usage

LocalDataPopulationChangeUnit.java

@RequiredArgsConstructor
@Slf4j
@ConditionalOnExpression("${initial.data.population:true}")
//@ConditionalOnProperty(prefix="initial.data", name = "population", havingValue ="true")
@ChangeUnit(id = "local-data-population", order = "999", author = "david.vuletas")
public class LocalDataPopulationChangeUnit {
....

application.yml

initial:
  data:
    population: false
@dieppa
Copy link
Member

dieppa commented Oct 16, 2023

Hello @davidvuletas ,

you have to take into account that, although ChangeUnits support dependency injection from the Spring context and profiles, they are not beans. They are POJO's managed by Mongock.
We have in our road map adding support for SpEL and that kind of annotations. Meanwhile you can workaround this with @profiles.

Also we wil create a contribution ticket to support this ind of feature, you are welcome to take it and raise a PR. We'll support you all way long and you will be displayed in our contributors page 😄

@vladimirsvicevicsrb
Copy link

I came across the same requirement. +1 vote for the same feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants