Package Migration - Propertytype is not ...
# package-development
k
We are building a reusable components package, that gets rolled out to different instances, and as a package owner we continuously introduce changes in Data Types and Document Types, either we are rolling out new features or for bug fixes, using Umbraco packages those updates are not reflected when releasing new packages, only new additions is reflected but updates to Doc Types or Data Templates are ignored, uSync is not an option for Nuget Package option. Is there a way to tell the Migration plan to always override whatever exists on Umbraco? I saw this thread https://github.com/umbraco/Umbraco-CMS/issues/13616 but I don't see any resolution from this thread
m
Updates to doctypes should be occuring in a packageMigration Plan, datatypes and templates though not.. https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs#L1081 You'd have to improve on the PackageDataInstallation if you wanted it to work.. you can programatically aslo do things outside of the automatic packagemigration from xml though..
templates once you have done the initial migration.. you should be able to do natively in the nuget package deploy files (with overwrite) or you can get involved doing (with your static guids for your package templates)..
Copy code
try
 {
     // update the master template with instafeed.js 
     var masterTemplate = _fileService.GetTemplate(new Guid("01656312-9988-4aef-a891-af119cae266f"));
     var filepath = masterTemplate.VirtualPath;
     var file = _hostEnvironment.MapPathContentRoot($"~{filepath}");

     if (System.IO.File.Exists(file))
     {
         string text = System.IO.File.ReadAllText(file);
         
//DO UPDATES HERE
             System.IO.File.WriteAllText(file, text);
         }
     }
 }
 catch (Exception e) { _logger.LogError(e, "master template update failed"); }
and same with dataypes via the
_dataTypeService.GetDataType(new Guid("GUID"));
now manipulate and thensave
_dataTypeService.Save(thedatatype);
One thing to watch out for is all notifications in a migrationplan are suppressed apart from a final agregated one.. https://github.com/umbraco/Umbraco-CMS/blob/41dddee620bc7a7c5c26d15550ee5f11111bf45c/src/Umbraco.Infrastructure/Install/PackageMigrationRunner.cs#L128 So for uSync/deploy purpose think you then do your resave of the datatype in that notificaiton to raise datatype changed events.. discord thread here where I got help from the community https://discord.com/channels/869656431308189746/1245696446301208616/1245779272493170740
k
Thanks will go through this and give it a try
For anyone who would come across this issue, We had combined Creating custom package migration approach along with the awesome uSync package, specifically the uSync.Backoffice package, so basically as a package composer we opted into serializing the package related items into a specific location and run uSync import api on the migrate method, you can define your own safeguards and conditions when to run or skip the migration but this is the basic idea https://gist.github.com/islamkhattab/70d6f9399db92c7c7537fed302caa8d0
2 Views