v10: Use ForceCreateDatabase during unattended install and extend GetUmbracoConnectionString extension methods (#12397)
* Add extension methods to get the Umbraco connection string/provider name from configuration
* Added tests for configuration extension methods.
* Fix issue with InstallMissingDatabase and ForceCreateDatabase
* Fix comments
* Revert casing change in GenerateConnectionString
* Re-add AddOptions (without config binding) to fix test
* Update src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs
Co-authored-by: Ronald Barendse <ronald@barend.se>
* Update src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs
* Update src/Umbraco.Infrastructure/Runtime/RuntimeState.cs
* Whitespace and documentation updates
* Add DatabaseProviderMetadataExtensions
* Filter before ordering
* Replace DataDirectory placeholder when setting connection string
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
(cherry picked from commit 8e6e262c7f)
This commit is contained in:
committed by
Bjarke Berg
parent
e90bf26577
commit
7087c3d9f6
@@ -2,8 +2,10 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Configuration.Models;
|
||||
|
||||
[UmbracoOptions("ConnectionStrings")]
|
||||
public class ConnectionStrings
|
||||
/// <summary>
|
||||
/// Represents a single connection string.
|
||||
/// </summary>
|
||||
public class ConnectionStrings // TODO: Rename to [Umbraco]ConnectionString (since v10 this only contains a single connection string)
|
||||
{
|
||||
private string? _connectionString;
|
||||
|
||||
@@ -15,20 +17,42 @@ public class ConnectionStrings
|
||||
/// <summary>
|
||||
/// The DataDirectory placeholder.
|
||||
/// </summary>
|
||||
public const string DataDirectoryPlaceholder = "|DataDirectory|";
|
||||
public const string DataDirectoryPlaceholder = ConfigurationExtensions.DataDirectoryPlaceholder;
|
||||
|
||||
/// <summary>
|
||||
/// The postfix used to identify a connection strings provider setting.
|
||||
/// </summary>
|
||||
public const string ProviderNamePostfix = "_ProviderName";
|
||||
public const string ProviderNamePostfix = ConfigurationExtensions.ProviderNamePostfix;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
[Obsolete("This property will be removed in Umbraco 12, because this class is now using named options.")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection string.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The connection string.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// When set, the <see cref="DataDirectoryPlaceholder"/> will be replaced with the actual physical path.
|
||||
/// </remarks>
|
||||
public string? ConnectionString
|
||||
{
|
||||
get => _connectionString;
|
||||
set => _connectionString = value?.ReplaceDataDirectoryPlaceholder();
|
||||
set => _connectionString = ConfigurationExtensions.ReplaceDataDirectoryPlaceholder(value);
|
||||
}
|
||||
|
||||
public string? ProviderName { get; set; } = DefaultProviderName;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the provider.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name of the provider.
|
||||
/// </value>
|
||||
public string? ProviderName { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user