Skip to content
Discussion options

You must be logged in to vote

This is probably happening because by default Mongock wraps the changeUnit within a transaction. However, MongoDB doesn't allow DDL operations within transactions.

To fix, you can mark your changeUnit with transactional=false, as follow:

@ChangeUnit(id="addPartialIndexToCoaching", order = "0001", author = "user1", transactional = false)
@Slf4j
public class AddIndexToCoaching {

  @Execution
  public void addPartialIndexToCoaching(MongoTemplate mongoTemplate) {
    // Create the index fields and sorting
    Document indexFields = new Document()
        .append("field1", 1)
        .append("field2", 1)
        .append("field3", 1);

    // Define the partial filter expression using Criteria

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@vallishk
Comment options

@dieppa
Comment options

@vallishk
Comment options

@dieppa
Comment options

@vallishk
Comment options

Answer selected by dieppa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants