diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertBlockEditorPropertiesBase.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertBlockEditorPropertiesBase.cs index 569f21afd2f9..20824b80b286 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertBlockEditorPropertiesBase.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertBlockEditorPropertiesBase.cs @@ -144,24 +144,14 @@ private bool Handle(IPropertyType[] propertyTypes, IDictionary l var progress = 0; - Parallel.ForEachAsync(updateBatch, async (update, token) => + void HandleUpdateBatch(UpdateBatch update) { - //Foreach here, but we need to suppress the flow before each task, but not the actuall await of the task - Task task; - using (ExecutionContext.SuppressFlow()) - { - task = Task.Run(() => - { - using ICoreScope scope = _coreScopeProvider.CreateCoreScope(); - scope.Complete(); - using UmbracoContextReference umbracoContextReference = - _umbracoContextFactory.EnsureUmbracoContext(); + using UmbracoContextReference umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext(); progress++; if (progress % 100 == 0) { - _logger.LogInformation(" - finíshed {progress} of {total} properties", progress, - updateBatch.Count); + _logger.LogInformation(" - finíshed {progress} of {total} properties", progress, updateBatch.Count); } PropertyDataDto propertyDataDto = update.Poco; @@ -169,8 +159,7 @@ private bool Handle(IPropertyType[] propertyTypes, IDictionary l // NOTE: some old property data DTOs can have variance defined, even if the property type no longer varies var culture = propertyType.VariesByCulture() && propertyDataDto.LanguageId.HasValue - && languagesById.TryGetValue(propertyDataDto.LanguageId.Value, - out ILanguage? language) + && languagesById.TryGetValue(propertyDataDto.LanguageId.Value, out ILanguage? language) ? language.IsoCode : null; @@ -256,11 +245,37 @@ private bool Handle(IPropertyType[] propertyTypes, IDictionary l stringValue = UpdateDatabaseValue(stringValue); propertyDataDto.TextValue = stringValue; - }, token); - } + } - await task; - }).GetAwaiter().GetResult(); + if (DatabaseType == DatabaseType.SQLite) + { + // SQLite locks up if we run the migration in parallel, so... let's not. + foreach (UpdateBatch update in updateBatch) + { + HandleUpdateBatch(update); + } + } + else + { + Parallel.ForEachAsync(updateBatch, async (update, token) => + { + //Foreach here, but we need to suppress the flow before each task, but not the actuall await of the task + Task task; + using (ExecutionContext.SuppressFlow()) + { + task = Task.Run( + () => + { + using ICoreScope scope = _coreScopeProvider.CreateCoreScope(); + scope.Complete(); + HandleUpdateBatch(update); + }, + token); + } + + await task; + }).GetAwaiter().GetResult(); + } updateBatch.RemoveAll(updatesToSkip.Contains);