commit9ff06eec6eAuthor: Ronald Barendse <ronald@barend.se> Date: Wed May 25 11:16:39 2022 +0200 v10: Instantly reload ConnectionStrings after saving configuration (#12475) * Do not replace DataDirectory placeholder when setting connection string * Ensure ConnectionStrings options are updated when configuration is reloaded * Use CurrentValue to get default Umbraco connection string commitfcee6dc06aAuthor: Paul Johnson <pmj@umbraco.com> Date: Wed May 25 10:08:43 2022 +0100 Fix legacy scope provider no longer implementing ICoreScopeProvider (#12480) commit88f3628d0aAuthor: Paul Johnson <pmj@umbraco.com> Date: Wed May 25 09:49:33 2022 +0100 Fix options monitor setup for connectionstrings (#12472) commit4eeb03e7fbAuthor: Johan Runsten <jrunestone@users.noreply.github.com> Date: Wed May 25 10:13:25 2022 +0200 Fixed null check typo in CacheInstructionService. Fixes #12473. (#12474) * Fixed null check typo. Fixes #12473. * Removed unneccessary null forgiving operator Co-authored-by: Johan Runsten <johan.runsten@toxic.se> commitd810d66e9aAuthor: Asbjørn Riis-Knudsen <ar@jf-data.com> Date: Tue May 24 17:41:10 2022 +0200 Fix #12454 by having Coalesce handle null values (#12456) * Fix #12454 by having Coalesce handle null values * Allow null values in Html.Coalesce #12454 commit963d4c5051Author: Paul Johnson <pmj@umbraco.com> Date: Tue May 24 13:55:39 2022 +0100 Ensure unique buildnumber for devops UI
91 lines
3.6 KiB
C#
91 lines
3.6 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Configuration;
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
using Umbraco.Cms.Core.Install;
|
|
using Umbraco.Cms.Core.Install.Models;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Infrastructure.Migrations.Install;
|
|
using Umbraco.Cms.Infrastructure.Migrations.PostMigrations;
|
|
using Umbraco.Cms.Infrastructure.Migrations.Upgrade;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Infrastructure.Install.InstallSteps
|
|
{
|
|
[InstallSetupStep(InstallationType.Upgrade | InstallationType.NewInstall, "DatabaseUpgrade", 12, "")]
|
|
public class DatabaseUpgradeStep : InstallSetupStep<object>
|
|
{
|
|
private readonly DatabaseBuilder _databaseBuilder;
|
|
private readonly IRuntimeState _runtime;
|
|
private readonly ILogger<DatabaseUpgradeStep> _logger;
|
|
private readonly IUmbracoVersion _umbracoVersion;
|
|
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
|
|
|
|
public DatabaseUpgradeStep(
|
|
DatabaseBuilder databaseBuilder,
|
|
IRuntimeState runtime,
|
|
ILogger<DatabaseUpgradeStep> logger,
|
|
IUmbracoVersion umbracoVersion,
|
|
IOptionsMonitor<ConnectionStrings> connectionStrings)
|
|
{
|
|
_databaseBuilder = databaseBuilder;
|
|
_runtime = runtime;
|
|
_logger = logger;
|
|
_umbracoVersion = umbracoVersion;
|
|
_connectionStrings = connectionStrings;
|
|
}
|
|
|
|
public override Task<InstallSetupResult?> ExecuteAsync(object model)
|
|
{
|
|
var installSteps = InstallStatusTracker.GetStatus().ToArray();
|
|
var previousStep = installSteps.Single(x => x.Name == "DatabaseInstall");
|
|
var upgrade = previousStep.AdditionalData.ContainsKey("upgrade");
|
|
|
|
if (upgrade)
|
|
{
|
|
_logger.LogInformation("Running 'Upgrade' service");
|
|
|
|
var plan = new UmbracoPlan(_umbracoVersion);
|
|
plan.AddPostMigration<ClearCsrfCookies>(); // needed when running installer (back-office)
|
|
|
|
var result = _databaseBuilder.UpgradeSchemaAndData(plan);
|
|
|
|
if (result?.Success == false)
|
|
{
|
|
throw new InstallException("The database failed to upgrade. ERROR: " + result.Message);
|
|
}
|
|
}
|
|
|
|
return Task.FromResult((InstallSetupResult?)null);
|
|
}
|
|
|
|
public override bool RequiresExecution(object model)
|
|
{
|
|
// If it's properly configured (i.e. the versions match) then no upgrade necessary
|
|
if (_runtime.Level == RuntimeLevel.Run)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// This step relies on the previous one completed - because it has stored some information we need
|
|
var installSteps = InstallStatusTracker.GetStatus().ToArray();
|
|
if (installSteps.Any(x => x.Name == "DatabaseInstall" && x.AdditionalData.ContainsKey("upgrade")) == false)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (_connectionStrings.CurrentValue.IsConnectionStringConfigured())
|
|
{
|
|
// A connection string was present, determine whether this is an install/upgrade
|
|
// Return true (upgrade) if there is an installed version, else false (install)
|
|
var result = _databaseBuilder.ValidateSchema();
|
|
return result?.DetermineHasInstalledVersion() ?? false;
|
|
}
|
|
|
|
// No connection string configured, probably a fresh install
|
|
return false;
|
|
}
|
|
}
|
|
}
|