Skip to content

@Profile annotation on legacy @ChangeSet/@Changelog is ignored during Flamingock execution #933

Description

@Celmas

@Profile annotation on legacy @ChangeSet/@Changelog is ignored during Flamingock execution

Description

We have a legacy Mongock @ChangeSet/@Changelogannotated with Spring's @Profile("unit", "init-db"), intended to run only when one of those profiles is active:

@ChangeLog(order = "050")
public class MongoChangelog50 {

    @Profile({"unit", "init-db"})
    @ChangeSet(author = "team", order = "1", id = "INIT-DB-seed-test-data")
    public void seedTestData(MongoDatabase mongoDatabase) {
        // seed logic intended only for test/init-db profiles
    }
}

After migrating to Flamingock (mongock-support), this change is executed even when neither unit nor init-db profile is active. It appears Flamingock's legacy change discovery/execution does not check Spring's @Profile condition before running the change — it simply discovers all @ChangeSet/@ChangeUnit methods on the classpath and executes them regardless of active profiles.

Environment

  • Java 21
  • Spring Boot 3.5.14
  • Flamingock 1.4.3

Expected behavior

Flamingock should respect Spring's @Profile annotation on legacy Mongock changes (same behavior as Mongock, which honored @Profile via Spring's ConditionEvaluator) and skip execution when none of the specified profiles are active.

Actual behavior

The change runs unconditionally, regardless of active profile, which in our case caused test/init-only seed data logic to run in non-test environments.

Impact

This is potentially a serious issue for teams relying on @Profile-gated legacy changes (e.g., test data seeding, environment-specific one-off scripts), since migrating to Flamingock silently changes execution behavior without any error or warning.

Suggested fix

When discovering/executing legacy Mongock @ChangeUnit/@ChangeSet classes, Flamingock should check for Spring's @Profile annotation on the class or method and evaluate it against the active profiles (via Spring's Environment#acceptsProfiles) before executing, mirroring Mongock's original behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions