Add AsyncMigrationBase, update base classes and call async methods#17057
Add AsyncMigrationBase, update base classes and call async methods#17057AndyButland merged 10 commits intov16/devfrom
AsyncMigrationBase, update base classes and call async methods#17057Conversation
|
|
||
| [Obsolete] | ||
| private void HandlePostMigrations(ExecutedMigrationPlan result) | ||
| private async Task HandlePostMigrationsAsync(ExecutedMigrationPlan result) |
There was a problem hiding this comment.
The post migrations have been obsoleted for a while (even stated for removal in v13, which didn't happen), but removing them should be done in a separate PR.
| namespace Umbraco.Cms.Infrastructure.Migrations; | ||
|
|
||
| public class NoopMigration : MigrationBase | ||
| public class NoopMigration : AsyncMigrationBase |
There was a problem hiding this comment.
This could be reverted back to MigrationBase to avoid an extra breaking change (so the base class doesn't change)... We have similar base class changes in UnscopedMigrationBase and PackageMigrationBase, which also don't inherit from MigrationBase anymore, but can't be fixed (because you can't simultaneously inherit from two base classes).
|
To me, I seems like there is a lot of breaking changes, that is not strictly necessary. Couldn't we let all the existing logic work as obsoleted, but introduce async migrations next to the existing. Thereby you would not have to change any base classes, you could just make a new version of the classes, E.g. NoopMigrationAsync |
|
I'm minded that we don't accept this one. I've tried, but I can't find a clean way to do it in a non-breaking way, and even if we accept breaking changes across majors it'll impact a lot of packages, which we likely don't want to unnecessarily do. Given migrations are one-off tasks on start-up only after an upgrade, and not something we expect to happen under heavy load, it feels like the benefit of async here may not be worth the disruption. Again, I'll run it by the team for opinions first. |
The only real breaking change would be the requirement to call |
|
This pull request has been mentioned on Umbraco community forum. There might be relevant details there: https://forum.umbraco.com/t/package-migration-plans-do-they-support-async-at-all/316/6 |
# Conflicts: # src/Umbraco.Infrastructure/Install/UnattendedUpgrader.cs # tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs
|
I've been looking at this some more this morning, so have now:
|
Prerequisites
Description
Similar to #16536, this PR makes it possible to (correctly) call async methods in migrations. I've done the following:
AsyncMigrationBasewith newRunAsync()andMigrateAsync()methods, made this the base class ofMigrationBaseand moved most methods into this new class;UnscopedAsyncMigrationBaseand made this the base class ofUnscopedMigrationBase, addedAsyncPackageMigrationBaseand made this the base class ofPackageMigrationBase;IMigrationPlanExecutorto only have anExecutePlanAsync()method;Testing should be done by ensuring a clean install creates and updates the database correctly and checking whether the code and tests are all good 😄