migrateAction method

String migrateAction(
  1. NUIDBEntityTracker entity
)

Implementation

String migrateAction(NUIDBEntityTracker entity){
  final changes = structureChanges(entity);

  bool hasFieldRemoved = false;
  bool hasFieldAdded = false;
  bool hasFieldUpdated = false;
  bool hasChangedCompletely = false;

  for(String value in changes.values){
    if(match(value, _ADDED)){
      hasFieldAdded = true;
    }
    if(match(value, _UPDATED)){
      hasFieldUpdated = true;
    }
    if(match(value, _REMOVED)){
      hasFieldRemoved = true;
    }
    if(match(value, _REMOVED_PRIMARY)){
      hasChangedCompletely = true;
    }
  }

  if(hasChangedCompletely) return ACTION_RECREATE;
  if(hasFieldRemoved || hasFieldUpdated) return ACTION_RECREATE_PATCH;
  if(hasFieldAdded) return ACTION_UPDATE;
  return ACTION_NONE;
}