-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataType Update during packageMigration completed then overwritten by uSync import at startup #640
Comments
Hi, I think the issue is probibly that the migrations are running before uSync has been able to register for the notification events, so it can't listen for them. if you can you could look at triggering the migrations after the uSyncComposer has ran, but i don't think you can do that with a package migration, you would have to look at using the core migrations (which are very similar) as you have greater control over when they run in the sequence. I don't think we can get uSync to be registred before package migrations because they happen in the core. Kevin |
That makes perfect sense, thank you for the swift response. |
Pushing my luck.. so core migrators, are we talking https://cornehoskam.com/posts/how-to-create-run-migrations-umbraco-v10 and the https://docs.umbraco.com/umbraco-cms/extending/database#schema-class-and-migrations approach? rather than https://docs.umbraco.com/umbraco-cms/extending/packages/creating-a-package#package-migration |
Yes, also some samples here |
superstar! I presume I just loose the |
Also, if you add the ComposeAfter tag it will run after uSync's composer. [ComposeAfter(typeof(uSync.BackOffice.uSyncBackOfficeComposer))]
public class MyComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
throw new System.NotImplementedException();
}
} in order to ensure that uSync (and umbraco) has fully started up before you do anything, you should run your migration code in a Started happens slightly later, and after the DB and everything are installed and randomly the language service has been populated with all the correct translations (so will work after installs and upgrades everytime) |
yes, you loose the 'run migration' button, your package will still showup in the back office just without that. |
Definately pushing my luck now.. ;-) |
Oh, I think you have to be very clever with reflection, but i am not 100% sure how. |
So looks like things get done in the right order now at least according to the logs.. but that no notifications are raised from a
Even added a simple public class DoStuffContentNotificationHandler : INotificationHandler<DataTypeSavingNotification>
{
private readonly ILogger _logger;
public DoStuffContentNotificationHandler(ILogger<DoStuffContentNotificationHandler> logger)
{
_logger = logger;
}
public void Handle(DataTypeSavingNotification notification)
{
_logger.LogDebug("Don't shout");
}
}
public class DontShoutComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<DataTypeSavingNotification, DoStuffContentNotificationHandler>();
}
} with [ComposeAfter(typeof(DontShoutComposer))]
public class HeroWidgetInnerOverlayStrengthMigrationComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<UmbracoApplicationStartedNotification, HeroWidgetInnerOverlayStrengthMigration>();
}
} Notification gets handled when using the backoffice, but not from the migration plan :-( Think I exhausted the breath of my capability now.. will have to ship with some directions on uSync integration... I also noticed that the core packagemigrator, persists dataypesection folder keys (guids) as well as names from the xml, uSync configs only carry the name..
|
FYI just tested with a cloud project and uda's aren't created by umbraco Deploy either... |
Hi, for the last bit yes, usync doesn't sync folders explicitly, rather it syncs items in folders and creates the folders as needed, instead when a doctype is saved/created/etc the folder is located by name or created new if needed. |
I think there is a scenario where folder keys have merit. (much like why node keys are bestpractice UID) package installs a folder, user changes name of if.. package ships an update and wants to put item in the same folder, with a key we can find it. But name only we generate a new folder with the old name? Also packagemigration created doctypes seem to get a uda created.. but not manual use of the datatypeservice.save() can't see anything extra going on in https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs 🤔 |
I'm running into the same issues here as well and for me this is a very VERY serious issue. I have a package that has a migration that adds an additional property to a media type. When using the PackageMigration, it doesn't work as mentioned above, because the property is added in the migration and uSync removes it again if it runs after that. So I don't mind rewriting the PackageMigration to a BaseMigration also as mentioned above. So I did that and that works....until the site is restarted. I don't want my package to have a dependency on uSync, so I can't specify ComposeAfter, but still, it seems that the migration is run after uSync. So far so good, but there is no usync file that gets updated, like @mistyn8 mentioned. So the next time uSync runs, it will again remove the property from my media type. This is a very serious issue for me, because that makes migrations practically useless for anything that touches uSync controlled content. Isn't there a way to tell uSync to export that specific media type, so it updates the files? I see the ContentTypeHandler as a good candidate, but the parameters seem quite complex :P |
after a discussion on discord.. workaround is to hook into the post migration handler.. (fired when all package migration required at runtime are complete) you can then do something like this to once if save to do go and use the services to resave any changes you've made and uSync I think will get it's notifications that things have changed.
|
And the reason is that actions done in the migration itself does not trigger notifications that uSync relies upon? And this solution simply 'retriggers' the notifications by performing them again? It might work, especially if I check if uSync is event installed. It's tricky though. If the migrations succeeds, but the 'MigrationPlansExecutedNotification' fails, you can get weird results. Still think it would be nice if I could just tell uSync to export a certain content or media type when it's updated. |
Simply that a user installs two packages from different developers at the same time, my packages removes something that the other package relies on and boom we have a fire. |
Ok thanks :) |
yeah that's the issue though all notifications are suppressed during migrations.. https://discord.com/channels/869656431308189746/1245696446301208616/1245779272493170740 |
I know there is a lot in the discord discussion and i need to re-read this, but Umbraco's behavior isn't consistent here. content item notifications is fired during a package migration and uSync handles them fine (because our notifications are registered before the migrations run). but datatype, document type, etc notifications don't fire, (and really, they should). it might be that the content notifications are delayaed and the others are not - but even then i do think we are ready for them before they run, so really we should be getting something 🤔 Investigating if we can tell if a migration has just ran, cause then we could do an export to try and get them, or we can put some form of notification in that could be triggered to do something by a migration. |
Some investigation the i think the best thing to do is the thing at the very top, if you are habitually using package migrations to update you should disable the automated package migrations (like deploy does in cloud) the reason we wouldn't do this for uSync is that we do not prescribe setup so can't say how you will have production, live, QA, dev setup, so it would be a user based choice if you wanted to do this. Our options:
We can certainly do the last one My gut still thinks this is a core umbraco needs sorting issue, notifications shouldn't be 'iffy' regardless of when they run. |
umb 13.1.1, uSync 13.1.1
I've written a package migration that as part of it's role updates a dataype configuration (blocklist)
However, although this works as expected, adding uSync into the mix causes the update to be reverted as
importAtStartup : Settings
is in use.Is it that the notification service isn't present to let uSync know that a dataType has changed?
If so can we manually notify uSync? I do seem to remember there was a
savewithevents
in days gone past is that something that's missing?Any pointers so that my migration supports uSync greatfully recieved
simplified code
The text was updated successfully, but these errors were encountered: