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 1 commit
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,27 @@
using System;
using System.Collections.Generic;
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));

foreach (var feature in features)
{
await dataMigrationManager.UpdateAsync(feature);
}
hishamco marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down Expand Up @@ -28,7 +29,14 @@ 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)
{
foreach (var feature in features)
{
await UpdateAsync(feature);
}
}

/// <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