I have a class
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document("animal")
public class Animal {
private String id;
private boolean isBirthYear;
}
I want to update class to:
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document("animal")
public class Animal {
private String id;
private long isBirthYear;
}
Don’t care about code convention. I want to write a migration to convert data from boolean to long in mongodb.
I try to create a new class
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document("animal")
public class AnimalV2 {
private String id;
private long isBirthYear;
}
but I think that is not a good solution.
2
Answers
As I think that you are looking for a a way to manage this migration with Mongock, I recommend to perform the actual MongoDB migration that @wpdnqd is providing inside a ChangeUnit.
Something like this
For more example, take a look to this repo and the official documentation