Skip to content
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

Replace IDataMigrationManager.UpdateAsync(string) with IDataMigrationManager.UpdateAsync(IEnumerable<string>) #15909

Merged
merged 7 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OrchardCore.Data.Migration;

/// <summary>
/// Provides an extension methods for <see cref="IDataMigrationManager"/>.
/// </summary>
public static class DataMigrationManagerExtensions
{
/// <summary>
/// Updates the database to the latest version for the specified features.
/// </summary>
/// <param name="dataMigrationManager">The <see cref="IDataMigrationManager"/>.</param>
/// <param name="features">The features to be updated.</param>
public static async Task UpdateAsync(this IDataMigrationManager dataMigrationManager, IEnumerable<string> features)
{
ArgumentNullException.ThrowIfNull(dataMigrationManager, nameof(dataMigrationManager));
ArgumentNullException.ThrowIfNull(features, nameof(features));

await Task.WhenAll(features.Select(dataMigrationManager.UpdateAsync));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail queries under everything but SQLite, don't use parallelization for SQL queries.

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OrchardCore.Data.Migration
Expand Down Expand Up @@ -28,7 +30,8 @@ public interface IDataMigrationManager
/// Updates the database to the latest version for the specified features.
/// </summary>
/// <param name="features">The features to be updated.</param>
Task UpdateAsync(IEnumerable<string> features);
[Obsolete("This method has been deprecated and moved into an extension method.")]
async Task UpdateAsync(IEnumerable<string> features) => await Task.WhenAll(features.Select(UpdateAsync));
hishamco marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Execute a script to delete any information relative to the feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,6 @@ public async Task Uninstall(string feature)
}
}

public async Task UpdateAsync(IEnumerable<string> featureIds)
{
foreach (var featureId in featureIds)
{
if (!_processedFeatures.Contains(featureId))
{
await UpdateAsync(featureId);
}
}
}

public async Task UpdateAsync(string featureId)
{
if (_processedFeatures.Contains(featureId))
Expand All @@ -152,7 +141,10 @@ public async Task UpdateAsync(string featureId)
.Where(x => x.Id != featureId)
.Select(x => x.Id);

await UpdateAsync(dependencies);
foreach (var dependency in dependencies)
{
await UpdateAsync(dependency);
}

var migrations = GetDataMigrations(featureId);

Expand Down