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

Remove double database connection validation in setup #12826

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -19,8 +19,4 @@
<ProjectReference Include="..\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Setup.Abstractions\OrchardCore.Setup.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="YesSql.Abstractions" />
</ItemGroup>
</Project>
26 changes: 6 additions & 20 deletions src/OrchardCore/OrchardCore.Setup.Core/SetupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OrchardCore.Abstractions.Setup;
using OrchardCore.Data;
using OrchardCore.Data.YesSql;
using OrchardCore.Environment.Shell;
using OrchardCore.Environment.Shell.Builders;
using OrchardCore.Environment.Shell.Descriptor;
Expand All @@ -20,7 +18,6 @@
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using OrchardCore.Setup.Events;
using YesSql;

namespace OrchardCore.Setup.Services
{
Expand Down Expand Up @@ -202,32 +199,21 @@ private async Task<string> SetupInternalAsync(SetupContext context)
{
await shellContext.CreateScope().UsingServiceScopeAsync(async scope =>
{
IStore store;

try
{
store = scope.ServiceProvider.GetRequiredService<IStore>();
// Create the "minimum shell descriptor"
await scope
.ServiceProvider
.GetService<IShellDescriptorManager>()
.UpdateShellDescriptorAsync(0,
shellContext.Blueprint.Descriptor.Features);
}
catch (Exception e)
{
// Tables already exist or database was not found

// The issue is that the user creation needs the tables to be present,
// if the user information is not valid, the next POST will try to recreate the
// tables. The tables should be rolled back if one of the steps is invalid,
// unless the recipe is executing?

_logger.LogError(e, "An error occurred while initializing the datastore.");
context.Errors.Add(String.Empty, S["An error occurred while initializing the datastore: {0}", e.Message]);
return;
}

// Create the "minimum shell descriptor"
await scope
.ServiceProvider
.GetService<IShellDescriptorManager>()
.UpdateShellDescriptorAsync(0,
shellContext.Blueprint.Descriptor.Features);
});

if (context.Errors.Any())
Expand Down