SitecoreUnicorn / Unicorn

A Sitecore utility designed to simplify deployment of Sitecore items across environments automatically
MIT License
269 stars 116 forks source link

Moved item can end up deleted on sync #435

Open Joentje71 opened 1 year ago

Joentje71 commented 1 year ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? When an item, for instance a template item, is moved between different projects, it can end up deleted on the first sync run. Depending on the Helix layers between which it is moved, it can go wrong. If it is moved from the project layer to a feature, it ends up deleted. But it might be our team that has the unicorn configuration wrong.

If the current behavior is a bug, please provide the steps to reproduce.

  1. existing item under Project.Website (Helix project layer)
  2. move it to Feature.Something project
  3. do a unicorn sync and notice the order in which the projects are synced:
    • first, the feature is synced: the item is [U] by unicorn (I think the update includes the path, among other fields)
    • after that, the Project.Website is synced: the item is [D] by unicorn, "because it did not exist in the serialization provider"

What is the expected behavior? We would like the item not to be deleted, because it still exists, only in a different project. I think dependencies cannot solve this easily, because it is not the dependency that creates the problem. After all, at the same time another item could be moved the other way, from feature to project layer. Somehow, unicorn should be aware of adds/deletes across different projects

Please mention your Sitecore version and Unicorn version. Sitecore 10.2.0 and unicorn 4.1.6

cassidydotdk commented 1 year ago

You really should have only 1 or at most a couple of Unicorn configurations.

That aside; Unicorn can handle a move across configurations under other circumstances. I think you're possibly stumbling somwhere, in how you execute the above steps. E.g. not ensuring your serialization datastore is kept in sync properly and/or not executing a full sync when required.

existing item under Project.Website (Helix project layer) move it to Feature.Something project

Aight. So on the instance you're doing this, the .yml file will be deleted from Project.Website and a new .yml file will appear unter Feature.Something

do a unicorn sync and notice the order in which the projects are synced

So the question here is; how did you move your files to the target environment where you now execute this sync? Did you make sure to clean out your deployment target so that the (on local) deleted .yml file from Project.Website got cleared out?

first, the feature is synced: the item is [U] by unicorn (I think the update includes the path, among other fields)

This would suggest you did not.

after that, the Project.Website is synced: the item is [D] by unicorn, "because it did not exist in the serialization provider"

And this is expected behaviour.