Conditional migration #897
Replies: 6 comments 5 replies
-
|
Hi @elvislicsari , Thanks for the detailed explanation. Before suggesting a concrete approach, I would like to understand the use case a bit better, because I’m not fully sure what you are trying to model here. In Mongock, So I would like to understand your requirement more precisely:
This last point is important because those two cases have different semantics. If the change is expected to run once, then it still behaves like a regular migration/change, just with some kind of external readiness condition. But if the change is expected to run more than once, then it is not really a normal ordered migration anymore. It becomes more like a recurring/reconciliation task. For example, if you have changes
And if a new change
That makes the relationship between ordering, audit history, and repeated execution less straightforward. It may still be valid for your use case, but we need to understand whether the order between normal changes and repeated conditional changes matters to you. The reason I’m asking is that
Also, Depending on your exact use case, there may be a few possible approaches, but I’d rather not suggest the wrong one before understanding the semantics you need. Could you share a bit more context about the external condition, whether the change should run once or multiple times, and whether ordering with the rest of the changes matters in your scenario? Regards, |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Hi again, Just a quick update, was able to achieve what i needed.
|
Beta Was this translation helpful? Give feedback.
-
|
Hello, I think I understand your case better now, but I would like to dig a bit deeper so we can help with two things:
Let me first confirm my understanding. Your case You have some changes that should be applied conditionally, depending on external conditions such as environment, release date, feature flag state, or similar. Your solution in Mongock You were using If the condition was met, the change was applied. If the condition was not met, the change did nothing. Then, on the next Mongock execution, the same Your current approach in Flamingock From what I understand, you are using a separatestage for these conditional changes and triggering Flamingock manually(with Inside the conditional change, you evaluate the condition. If the condition is not met, you throw a known/custom exception. Then, outside Flamingock, you inspect the exception: if it is that known condition-not-met exception, you allow the application startup to continue; otherwise, you propagate the error. Please correct me if I misunderstood any part of this. Questions
With this information, we can better reason about a practical short-term approach and also whether Flamingock should support this use case more explicitly in the future. Thanks. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, that clarifies a lot. A couple more questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @elvislicsari, this is very helpful. I think we now have enough context to understand the use case properly. Your scenario makes sense to us, and we agree that it is relevant for Flamingock. Conditional changes tied to feature rollout, environment differences, or client-specific activation are valid use cases, especially when they are independent from the main ordered execution flow. We will approach this in two steps:
We still need to refine the exact design and semantics, especially around ordering, dependencies between conditional changes, audit state, and rollback behavior. But your input gives us a very clear direction. Thanks again for taking the time to explain the scenario in detail. This is exactly the kind of feedback that helps us shape Flamingock properly. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I would like to be able to run a migration when an external condition is met. Was able to do this using mongock with the runAlways = true on a @ChangeUnit.
Not sure i'm able to achieve this with flamingock out of the box.
So far i tried a @ConditionalOnProperty(name = "run.migration", havingValue = "true") applied on the Change class, but the migration was run anyway.
Tried also the Recovery(strategy = RecoveryStrategy.ALWAYS_RETRY) but the application doesn't start when any exception is being thrown from Apply method.
The last solution that comes to mind, is to start manually Flamingock migration, try/catch some custom ConditionalRetryableException thrown by Apply when condition is not met and continue with the application start-up.
Haven't put this to test yet as i don't really like doing things manually.
Is there any other better approach to achieve this ?
Thanks,
Elvis
Beta Was this translation helpful? Give feedback.
All reactions