I'm trying to transfer the previously created ID to other changesets in mongock. This is my solution but I don't know if it's correct. I will be grateful if you could share your proposition.
@ChangeLog(order = "001")
public class DatabaseChangelock {
private Map<String, ObjectId> myIdMap = new HashMap<>();
@ChangeSet(order = "001", id = "logs001", author = "Me")
public void userTest(UserEntityRepo user) {
UserEntity userEntity = new UserEntity;
userEntity.setName("Mike");
userEntity.setSurname("Smith");
user.save(userEntity);
myIdMap.put("test",userEntity.getId());
}
@ChangeSet(order = "002", id = "logs002", author = "Me")
public void factoryTest(FactoryEntityRepo factory) {
FactoryEntity factoryEntity = new FactoryEntity;
factoryEntity.setName("BigCompany");
factoryEntity.setBossId(myIdMap.get("test"));
factory.save(factoryEntity);
}
}