MigrationBase vs PackageMigrationBase
# package-development
m
I was working on some migration code for my small "Seo Visualizer" package during the weekend. This is a property editor and one of the things I needed to do was to change the
propertyEditorUiAlias
of the datatype during a upgrade to v14. I've been using
MigrationBase
for migrations since before
PackageMigrationBase
was introduced. I tried to use the
PackageMigrationBase
this time but it did not run during the upgrade from v13 to v14 - I had to restart the website again for it to run. I've tried to read the documentation but I can't really understand: * What is the difference between the "bare metal" migrations (MigrationBase) and the package-specific ones? (PackageMigrationBase)? * As a package dev, when should I use one over the other? * There is also a setting
Umbraco.Cms.PackageMigration.RunSchemaAndContentMigrations
, what is the idea here? When would a package consumer want to disable the package migrations? Is this to try to isolate them if there are issues in a certain package migration that prevent upgrades? I've noticed that there is a UI in the Developer-section so that consumers of a package can decide if they want to run package migrations or not - I don't get the idea here - how would one of my package consumers know that they need to click on this button? Does anyone have a good real-world use case for this that you could explain to help me understand? Cheers!
w
My memory serves me correctly its more to do with the package.xml so content, datatypes that you can generate from the backoffice that needs to be an embedded resource will be automatically run for you in a PackageMigrationBase
So you get access to alot of the stuff injected from DI for you to help with media & its files, contentTypes etc so a bit more than just DB'y things in the normal migration. So if you have a use for some of these things I would go with that to help save some plumbing but it doesn't operate any differently than a normal MigrationBase
If you use
AutomaticPackageMigrationPlan
it scans the assembly for a package.zip in the embedded resource, gets a hash of the file and sets that as the migration state to run to. https://github.com/umbraco/Umbraco-CMS/blob/4090829fe8bcb620b266547769d5372ac0b28c80/src/Umbraco.Infrastructure/Packaging/AutomaticPackageMigrationPlan.cs
Hope that helps @Markus Johansson
j
Yea I think the primary thought was packages that include schema or content which for any uSync/Deploy sites would then be added as schema files, you wouldnt want it to then automatically run that migration again on live and conflict with the generated usync/deploy files that were pushed up to the env
m
Ahh, that make sense, so mainly for packages that include schema or content, in that case it kind of make sense to manually trigger the migration.
Thanks for helping out 😄
16 Views