Core.Persistence - post-cleanup debugging
This commit is contained in:
@@ -54,26 +54,26 @@ namespace Umbraco.Core.Persistence
|
||||
/// </summary>
|
||||
/// <param name="sqlSyntaxProviders">The collection of available sql syntax providers.</param>
|
||||
/// <param name="logger">A logger.</param>
|
||||
/// <remarks>Used by LightInject.</remarks>
|
||||
public DefaultDatabaseFactory(IEnumerable<ISqlSyntaxProvider> sqlSyntaxProviders, ILogger logger)
|
||||
{
|
||||
if (sqlSyntaxProviders == null) throw new ArgumentNullException(nameof(sqlSyntaxProviders));
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
: this(GlobalSettings.UmbracoConnectionName, sqlSyntaxProviders, logger)
|
||||
{ }
|
||||
|
||||
_sqlSyntaxProviders = sqlSyntaxProviders.ToArray();
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// fixme - used once by the other ctor, and 5 times in various tests
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultDatabaseFactory"/> with a connection string name and a logger.
|
||||
/// </summary>
|
||||
/// <param name="connectionStringName">The name of the connection string in web.config.</param>
|
||||
/// <param name="sqlSyntaxProviders">The collection of available sql syntax providers.</param>
|
||||
/// <param name="logger">A logger</param>
|
||||
/// <remarks>Used by the other ctor and in tests.</remarks>
|
||||
public DefaultDatabaseFactory(string connectionStringName, IEnumerable<ISqlSyntaxProvider> sqlSyntaxProviders, ILogger logger)
|
||||
: this(sqlSyntaxProviders, logger)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(connectionStringName, "connectionStringName");
|
||||
if (sqlSyntaxProviders == null) throw new ArgumentNullException(nameof(sqlSyntaxProviders));
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName)) throw new ArgumentException("Value cannot be null nor empty.", nameof(connectionStringName));
|
||||
|
||||
_sqlSyntaxProviders = sqlSyntaxProviders.ToArray();
|
||||
_logger = logger;
|
||||
|
||||
var settings = ConfigurationManager.ConnectionStrings[connectionStringName];
|
||||
if (settings == null)
|
||||
@@ -82,7 +82,6 @@ namespace Umbraco.Core.Persistence
|
||||
Configure(settings.ConnectionString, settings.ProviderName);
|
||||
}
|
||||
|
||||
// fixme - used only once in tests
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultDatabaseFactory"/> with a connection string, a provider name and a logger.
|
||||
/// </summary>
|
||||
@@ -90,9 +89,15 @@ namespace Umbraco.Core.Persistence
|
||||
/// <param name="providerName">The name of the database provider.</param>
|
||||
/// <param name="sqlSyntaxProviders">The collection of available sql syntax providers.</param>
|
||||
/// <param name="logger">A logger.</param>
|
||||
/// <remarks>Used in tests.</remarks>
|
||||
public DefaultDatabaseFactory(string connectionString, string providerName, IEnumerable<ISqlSyntaxProvider> sqlSyntaxProviders, ILogger logger)
|
||||
: this(sqlSyntaxProviders, logger)
|
||||
{
|
||||
if (sqlSyntaxProviders == null) throw new ArgumentNullException(nameof(sqlSyntaxProviders));
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
_sqlSyntaxProviders = sqlSyntaxProviders.ToArray();
|
||||
_logger = logger;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString) || string.IsNullOrWhiteSpace(providerName))
|
||||
return; // not configured
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Migrations.Upgrades
|
||||
var targetVersion = new SemVersion(6, 0, 0);
|
||||
var db = GetConfiguredDatabase();
|
||||
|
||||
var fix = new PublishAfterUpgradeToVersionSixth(db.SqlSyntax);
|
||||
var fix = new PublishAfterUpgradeToVersionSixth();
|
||||
|
||||
//Setup the MigrationRunner
|
||||
var migrationRunner = new MigrationRunner(
|
||||
|
||||
@@ -18,13 +18,6 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
/// </remarks>
|
||||
public class ClearMediaXmlCacheForDeletedItemsAfterUpgrade : MigrationStartupHander
|
||||
{
|
||||
private readonly ISqlSyntaxProvider _sqlSyntax;
|
||||
|
||||
public ClearMediaXmlCacheForDeletedItemsAfterUpgrade(ISqlSyntaxProvider sqlSyntax)
|
||||
{
|
||||
_sqlSyntax = sqlSyntax;
|
||||
}
|
||||
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
if (e.ProductName != GlobalSettings.UmbracoMigrationName) return;
|
||||
@@ -36,10 +29,12 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
//This query is structured to work with MySql, SQLCE and SqlServer:
|
||||
// http://issues.umbraco.org/issue/U4-3876
|
||||
|
||||
var syntax = e.MigrationContext.Database.SqlSyntax;
|
||||
|
||||
var sql = @"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
(SELECT nodeId FROM (SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
|
||||
INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
|
||||
WHERE nodeObjectType = '" + Constants.ObjectTypes.Media + "' AND " + _sqlSyntax.GetQuotedColumnName("path") + " LIKE '%-21%') x)";
|
||||
WHERE nodeObjectType = '" + Constants.ObjectTypes.Media + "' AND " + syntax.GetQuotedColumnName("path") + " LIKE '%-21%') x)";
|
||||
|
||||
var count = e.MigrationContext.Database.Execute(sql);
|
||||
|
||||
|
||||
@@ -19,13 +19,6 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
/// </summary>
|
||||
public class EnsureDefaultListViewDataTypesCreated : MigrationStartupHander
|
||||
{
|
||||
private readonly ISqlSyntaxProvider _sqlSyntax;
|
||||
|
||||
public EnsureDefaultListViewDataTypesCreated(ISqlSyntaxProvider sqlSyntax)
|
||||
{
|
||||
_sqlSyntax = sqlSyntax;
|
||||
}
|
||||
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
if (e.ProductName != GlobalSettings.UmbracoMigrationName) return;
|
||||
@@ -41,13 +34,15 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
|
||||
private void EnsureListViewDataTypeCreated(MigrationEventArgs e)
|
||||
{
|
||||
var syntax = e.MigrationContext.Database.SqlSyntax;
|
||||
|
||||
using (var transaction = e.MigrationContext.Database.GetTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
//Turn on identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", _sqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", syntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
if (e.MigrationContext.Database.Exists<NodeDto>(Constants.System.DefaultContentListViewDataTypeId))
|
||||
{
|
||||
@@ -62,16 +57,16 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
finally
|
||||
{
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", _sqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", syntax.GetQuotedTableName("umbracoNode"))));
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
//Turn on identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", _sqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", syntax.GetQuotedTableName("cmsDataType"))));
|
||||
|
||||
e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = -26, DataTypeId = Constants.System.DefaultContentListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = -27, DataTypeId = Constants.System.DefaultMediaListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
@@ -80,8 +75,8 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
finally
|
||||
{
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", _sqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", syntax.GetQuotedTableName("cmsDataType"))));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +84,8 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
try
|
||||
{
|
||||
//Turn on identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", _sqlSyntax.GetQuotedTableName("cmsDataTypePreValues"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", syntax.GetQuotedTableName("cmsDataTypePreValues"))));
|
||||
|
||||
//defaults for the member list
|
||||
e.MigrationContext.Database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto { Id = -1, Alias = "pageSize", SortOrder = 1, DataTypeNodeId = Constants.System.DefaultMembersListViewDataTypeId, Value = "10" });
|
||||
@@ -101,8 +96,8 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
finally
|
||||
{
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (_sqlSyntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", _sqlSyntax.GetQuotedTableName("cmsDataTypePreValues"))));
|
||||
if (syntax.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", syntax.GetQuotedTableName("cmsDataTypePreValues"))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,13 +19,6 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
/// </summary>
|
||||
public class PublishAfterUpgradeToVersionSixth : MigrationStartupHander
|
||||
{
|
||||
private readonly ISqlSyntaxProvider _sqlSyntax;
|
||||
|
||||
public PublishAfterUpgradeToVersionSixth(ISqlSyntaxProvider sqlSyntax)
|
||||
{
|
||||
_sqlSyntax = sqlSyntax;
|
||||
}
|
||||
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
if (e.ProductName != GlobalSettings.UmbracoMigrationName) return;
|
||||
|
||||
Reference in New Issue
Block a user