Merge remote-tracking branch 'origin/v10/dev' into v11/dev
# Conflicts: # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # version.json
This commit is contained in:
@@ -36,7 +36,12 @@ public class DatabaseConfigureStep : InstallSetupStep<DatabaseModel>
|
||||
|
||||
public override Task<InstallSetupResult?> ExecuteAsync(DatabaseModel databaseSettings)
|
||||
{
|
||||
if (!_databaseBuilder.ConfigureDatabaseConnection(databaseSettings, false))
|
||||
if (databaseSettings is null && string.IsNullOrWhiteSpace(_connectionStrings.CurrentValue.ConnectionString) is false)
|
||||
{
|
||||
return Task.FromResult<InstallSetupResult?>(null);
|
||||
}
|
||||
|
||||
if (!_databaseBuilder.ConfigureDatabaseConnection(databaseSettings!, false))
|
||||
{
|
||||
throw new InstallException("Could not connect to the database");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration;
|
||||
using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_0_0;
|
||||
using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_2_0;
|
||||
using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_5_0;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade;
|
||||
|
||||
@@ -80,5 +81,8 @@ public class UmbracoPlan : MigrationPlan
|
||||
|
||||
// To 10.4.0
|
||||
To<V_10_4_0.AddBlockGridPartialViews>("{3F5D492A-A3DB-43F9-A73E-9FEE3B180E6C}");
|
||||
|
||||
// to 10.5.0 / 11.2.0
|
||||
To<AddPrimaryKeyConstrainToContentVersionCleanupDtos>("{83AF7945-DADE-4A02-9041-F3F6EBFAC319}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_5_0;
|
||||
|
||||
public class AddPrimaryKeyConstrainToContentVersionCleanupDtos : MigrationBase
|
||||
{
|
||||
public AddPrimaryKeyConstrainToContentVersionCleanupDtos(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Migrate()
|
||||
{
|
||||
IEnumerable<ContentVersionCleanupPolicyDto> contentVersionCleanupPolicyDtos =
|
||||
Database
|
||||
.Fetch<ContentVersionCleanupPolicyDto>()
|
||||
.OrderByDescending(x => x.Updated)
|
||||
.DistinctBy(x => x.ContentTypeId);
|
||||
|
||||
if (TableExists(ContentVersionCleanupPolicyDto.TableName))
|
||||
{
|
||||
Delete.Table(ContentVersionCleanupPolicyDto.TableName).Do();
|
||||
}
|
||||
|
||||
Create.Table<ContentVersionCleanupPolicyDto>().Do();
|
||||
Database.InsertBatch(contentVersionCleanupPolicyDtos);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ internal class ContentVersionCleanupPolicyDto
|
||||
public const string TableName = Constants.DatabaseSchema.Tables.ContentVersionCleanupPolicy;
|
||||
|
||||
[Column("contentTypeId")]
|
||||
[ForeignKey(typeof(ContentTypeDto), Column = "nodeId", OnDelete = Rule.Cascade)]
|
||||
[PrimaryKeyColumn(AutoIncrement = false)]
|
||||
[ForeignKey(typeof(ContentTypeDto), Column = "nodeId")]
|
||||
public int ContentTypeId { get; set; }
|
||||
|
||||
[Column("preventCleanup")]
|
||||
|
||||
@@ -180,6 +180,7 @@ internal class ContentTypeRepository : ContentTypeRepositoryBase<IContentType>,
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
var l = (List<string>)base.GetDeleteClauses(); // we know it's a list
|
||||
l.Add("DELETE FROM umbracoContentVersionCleanupPolicy WHERE contentTypeId = @id");
|
||||
l.Add("DELETE FROM cmsDocumentType WHERE contentTypeNodeId = @id");
|
||||
l.Add("DELETE FROM cmsContentType WHERE nodeId = @id");
|
||||
l.Add("DELETE FROM umbracoNode WHERE id = @id");
|
||||
|
||||
Reference in New Issue
Block a user