Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
41d0143
Adding TrackedReferencesController
elit0451 Jan 19, 2022
528ad1c
Adding/changing views
elit0451 Jan 19, 2022
0392f3d
Adding/Editing js files
elit0451 Jan 19, 2022
42e4a58
RelationService changes
elit0451 Jan 19, 2022
ebdc6a1
RelationRepository changes
elit0451 Jan 19, 2022
be70d92
Adding missing translations
elit0451 Jan 19, 2022
29672dc
Adding/Modifying tests
elit0451 Jan 19, 2022
3193670
Beginning of #9125 migration
elit0451 Jan 27, 2022
ad91a7d
Introducing a new component + refactoring based on that
elit0451 Jan 27, 2022
6ab4a3e
Abstracting + refactoring
elit0451 Jan 27, 2022
9da356a
Work on content unpublishing
elit0451 Jan 27, 2022
dab2384
Work on media.delete
elit0451 Jan 27, 2022
c7a42d4
Various small changes
elit0451 Jan 27, 2022
66eab0b
Beginning of #9119 migration
elit0451 Jan 27, 2022
3505c4b
Changes on content.delete
elit0451 Jan 27, 2022
b081f60
Various fixes
elit0451 Jan 28, 2022
fa3f8e2
Merge branch 'v9/dev' into v9/feature/item-tracking
elit0451 Jan 28, 2022
815ab04
Adding new keys used in the listview bulk actions
elit0451 Feb 10, 2022
36d2f8d
Adding methods to get the items used in relations from array of ids
elit0451 Feb 10, 2022
9477500
Adding the checkLinkedItems function to the trackedReferencesResource
elit0451 Feb 10, 2022
706fbb0
Passing the selected items from a listview to unpublish and delete
elit0451 Feb 10, 2022
f7b8ef1
Adding umb-tracked-references-listview
elit0451 Feb 10, 2022
d2bf55a
Adding umb-tracked-references-listview-table with language column
elit0451 Feb 10, 2022
f67ca53
Fixes for tracked references
elit0451 Feb 10, 2022
ec1ff97
Changes in listview unpublish dialog
elit0451 Feb 10, 2022
44e86d1
Changes in listview delete dialog
elit0451 Feb 10, 2022
03bfebf
Removing Variants logic as it is not currently supported
elit0451 Feb 10, 2022
3710890
Visual fixes
elit0451 Feb 10, 2022
74c1c75
Merge remote-tracking branch 'origin/v9/dev' into v9/feature/item-tra…
elit0451 Feb 10, 2022
7d71122
Closing dialogs on click
elit0451 Feb 13, 2022
7754781
Fix wording
elit0451 Feb 14, 2022
094eb8a
Fix breaking changes
elit0451 Feb 16, 2022
ead8da3
Merge remote-tracking branch 'origin/v9/dev' into v9/feature/item-tra…
elit0451 Feb 16, 2022
14a2459
Change to a single title "Items in use" instead of 2 different for Co…
elit0451 Feb 16, 2022
c6dbbe7
No need for obsoleting because we can change new controllers
elit0451 Feb 16, 2022
ee0135f
Return ActionResult from actions
elit0451 Feb 23, 2022
ed585ae
Merge remote-tracking branch 'origin/v9/dev' into v9/feature/item-tra…
elit0451 Feb 23, 2022
e185610
V9: Prevent delete or unpublish of items that have references (#12047)
elit0451 Feb 24, 2022
53fe129
V9: Displaying descendants in use as part of item tracking (#12039)
elit0451 Feb 24, 2022
f50eb90
rename busfy to busy
nielslyngsoe Mar 1, 2022
c992b31
Merge remote-tracking branch 'origin/v9/dev' into v9/feature/item-tra…
nielslyngsoe Mar 2, 2022
dd92898
always show references
nielslyngsoe Mar 2, 2022
7846f7b
rearrange for scrollbar to appear at the edge of the dialog
nielslyngsoe Mar 2, 2022
4fee8a9
use the word referenced instead of used
nielslyngsoe Mar 2, 2022
3f9c4e7
change fallback texts
nielslyngsoe Mar 2, 2022
d54a07c
Added "IsDependency" to relation types
bergmania Mar 2, 2022
a4a4445
Merge remote-tracking branch 'origin/v9/feature/item-tracking' into v…
bergmania Mar 2, 2022
cf4db21
refactor of umb-tracked-references
nielslyngsoe Mar 2, 2022
798b43b
rename checkLinkedItems to getPagedReferencedItems
nielslyngsoe Mar 3, 2022
8fce67b
rename check to load, to be consistent with the rest.
nielslyngsoe Mar 3, 2022
342d380
Merge remote-tracking branch 'origin/v9/feature/item-tracking' into v…
bergmania Mar 3, 2022
d606f36
Refactored backend . Needs frontend fixes
bergmania Mar 4, 2022
28de6d1
Cleanup
bergmania Mar 4, 2022
9cbc24a
Use filters
bergmania Mar 4, 2022
eaa9e8c
Front-end refactor to match refactored end-points
nielslyngsoe Mar 6, 2022
9d020e5
Fixed bug + warning
bergmania Mar 7, 2022
fb57ef4
Fixed query (more then 2100 descensdants) and optimized it (using nes…
bergmania Mar 7, 2022
c2238cb
remove comment
nielslyngsoe Mar 7, 2022
5a41d3e
hideNoneDependencies including varying text for the configuration
nielslyngsoe Mar 7, 2022
c5154c9
Merge branch 'v9/feature/item-tracking-refactor' of https://github.co…
nielslyngsoe Mar 7, 2022
89abb29
Hack for SqlCE :(
bergmania Mar 7, 2022
36226fd
some final adjustments for item tracking ui
nielslyngsoe Mar 7, 2022
ba044f2
Unbreak change
bergmania Mar 7, 2022
1e25256
Merge remote-tracking branch 'origin/v9/feature/item-tracking-refacto…
bergmania Mar 7, 2022
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
14 changes: 14 additions & 0 deletions src/Umbraco.Core/Configuration/Models/ContentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ @keyframes umbraco-preview-badge--effect {{
internal const string StaticLoginBackgroundImage = "assets/img/login.jpg";
internal const string StaticLoginLogoImage = "assets/img/application/umbraco_logo_white.svg";
internal const bool StaticHideBackOfficeLogo = false;
internal const bool StaticDisableDeleteWhenReferenced = false;
internal const bool StaticDisableUnpublishWhenReferenced = false;

/// <summary>
/// Gets or sets a value for the content notification settings.
Expand Down Expand Up @@ -226,6 +228,18 @@ @keyframes umbraco-preview-badge--effect {{
[DefaultValue(StaticHideBackOfficeLogo)]
public bool HideBackOfficeLogo { get; set; } = StaticHideBackOfficeLogo;

/// <summary>
/// Gets or sets a value indicating whether to disable the deletion of items referenced by other items.
/// </summary>
[DefaultValue(StaticDisableDeleteWhenReferenced)]
public bool DisableDeleteWhenReferenced { get; set; } = StaticDisableDeleteWhenReferenced;

/// <summary>
/// Gets or sets a value indicating whether to disable the unpublishing of items referenced by other items.
/// </summary>
[DefaultValue(StaticDisableUnpublishWhenReferenced)]
public bool DisableUnpublishWhenReferenced { get; set; } = StaticDisableUnpublishWhenReferenced;

/// <summary>
/// Get or sets the model representing the global content version cleanup policy
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Umbraco.Core/Events/RelateOnCopyNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public void Handle(ContentCopiedNotification notification)
Constants.Conventions.RelationTypes.RelateDocumentOnCopyName,
true,
Constants.ObjectTypes.Document,
Constants.ObjectTypes.Document);
Constants.ObjectTypes.Document,
false);

_relationService.Save(relationType);
}
Expand Down
6 changes: 6 additions & 0 deletions src/Umbraco.Core/Models/ContentEditing/RelationTypeDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@ public RelationTypeDisplay()
/// </summary>
[DataMember(Name = "notifications")]
public List<BackOfficeNotification> Notifications { get; private set; }

/// <summary>
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
/// </summary>
[DataMember(Name = "isDependency", IsRequired = true)]
public bool IsDependency { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Umbraco.Core/Models/ContentEditing/RelationTypeSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ public class RelationTypeSave : EntityBasic
/// </summary>
[DataMember(Name = "childObjectType", IsRequired = false)]
public Guid? ChildObjectType { get; set; }

/// <summary>
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
/// </summary>
[DataMember(Name = "isDependency", IsRequired = true)]
public bool IsDependency { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/Umbraco.Core/Models/IRelationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

namespace Umbraco.Cms.Core.Models
{
public interface IRelationTypeWithIsDependency : IRelationType
{
/// <summary>
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
/// </summary>
[DataMember]
bool IsDependency { get; set; }
}

public interface IRelationType : IEntity, IRememberBeingDirty
{
/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/Umbraco.Core/Models/Mapping/RelationMapDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ private void Map(IRelationType source, RelationTypeDisplay target, MapperContext
target.ChildObjectType = source.ChildObjectType;
target.Id = source.Id;
target.IsBidirectional = source.IsBidirectional;

if (source is IRelationTypeWithIsDependency sourceWithIsDependency)
{
target.IsDependency = sourceWithIsDependency.IsDependency;
}
target.Key = source.Key;
target.Name = source.Name;
target.Alias = source.Alias;
Expand Down Expand Up @@ -74,6 +79,11 @@ private static void Map(RelationTypeSave source, IRelationType target, MapperCon
target.ChildObjectType = source.ChildObjectType;
target.Id = source.Id.TryConvertTo<int>().Result;
target.IsBidirectional = source.IsBidirectional;
if (target is IRelationTypeWithIsDependency targetWithIsDependency)
{
targetWithIsDependency.IsDependency = source.IsDependency;
}

target.Key = source.Key;
target.Name = source.Name;
target.ParentObjectType = source.ParentObjectType;
Expand Down
44 changes: 44 additions & 0 deletions src/Umbraco.Core/Models/RelationItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Cms.Core.Models.Entities;

namespace Umbraco.Cms.Core.Models
{
[DataContract(Name = "relationItem", Namespace = "")]
public class RelationItem
{
[DataMember(Name = "id")]
public int NodeId { get; set; }

[DataMember(Name = "key")]
public Guid NodeKey { get; set; }

[DataMember(Name = "name")]
public string NodeName { get; set; }

[DataMember(Name = "type")]
public string NodeType { get; set; }

[DataMember(Name = "udi")]
public Udi NodeUdi => Udi.Create(NodeType, NodeKey);

[DataMember(Name = "icon")]
public string ContentTypeIcon { get; set; }

[DataMember(Name = "alias")]
public string ContentTypeAlias { get; set; }

[DataMember(Name = "contentTypeName")]
public string ContentTypeName { get; set; }

[DataMember(Name = "relationTypeName")]
public string RelationTypeName { get; set; }

[DataMember(Name = "relationTypeIsBidirectional")]
public bool RelationTypeIsBidirectional { get; set; }

[DataMember(Name = "relationTypeIsDependency")]
public bool RelationTypeIsDependency { get; set; }

}
}
19 changes: 17 additions & 2 deletions src/Umbraco.Core/Models/RelationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ namespace Umbraco.Cms.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public class RelationType : EntityBase, IRelationType
public class RelationType : EntityBase, IRelationType, IRelationTypeWithIsDependency
{
private string _name;
private string _alias;
private bool _isBidirectional;
private bool _isDependency;
private Guid? _parentObjectType;
private Guid? _childObjectType;

public RelationType(string alias, string name)
: this(name: name, alias: alias, false, null, null)
: this(name: name, alias: alias, false, null, null, false)
{
}

[Obsolete("Use ctor with isDependency parameter")]
public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType)
:this(name,alias,isBidrectional, parentObjectType, childObjectType, false)
{

}

public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType, bool isDependency)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
Expand All @@ -32,6 +40,7 @@ public RelationType(string name, string alias, bool isBidrectional, Guid? parent
_name = name;
_alias = alias;
_isBidirectional = isBidrectional;
_isDependency = isDependency;
_parentObjectType = parentObjectType;
_childObjectType = childObjectType;
}
Expand Down Expand Up @@ -88,5 +97,11 @@ public Guid? ChildObjectType
set => SetPropertyValueAndDetectChanges(value, ref _childObjectType, nameof(ChildObjectType));
}


public bool IsDependency
{
get => _isDependency;
set => SetPropertyValueAndDetectChanges(value, ref _isDependency, nameof(IsDependency));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;

namespace Umbraco.Cms.Core.Persistence.Repositories
{
public interface ITrackedReferencesRepository
{
IEnumerable<RelationItem> GetPagedRelationsForItems(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
Comment thread
elit0451 marked this conversation as resolved.
IEnumerable<RelationItem> GetPagedItemsWithRelations(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
IEnumerable<RelationItem> GetPagedDescendantsInReferences(int parentId, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
}
}
6 changes: 3 additions & 3 deletions src/Umbraco.Core/Services/IRelationService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
Expand Down Expand Up @@ -215,7 +215,7 @@ public interface IRelationService : IService
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="totalChildren"></param>
/// <returns></returns>
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
IEnumerable<IUmbracoEntity> GetPagedParentEntitiesByChildId(int id, long pageIndex, int pageSize, out long totalChildren, params UmbracoObjectTypes[] entityTypes);

/// <summary>
Expand All @@ -225,7 +225,7 @@ public interface IRelationService : IService
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="totalChildren"></param>
/// <returns></returns>
/// <returns>An enumerable list of <see cref="IUmbracoEntity"/></returns>
IEnumerable<IUmbracoEntity> GetPagedChildEntitiesByParentId(int id, long pageIndex, int pageSize, out long totalChildren, params UmbracoObjectTypes[] entityTypes);

/// <summary>
Expand Down
15 changes: 15 additions & 0 deletions src/Umbraco.Core/Services/ITrackedReferencesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Services
{
public interface ITrackedReferencesService
{
PagedResult<RelationItem> GetPagedRelationsForItems(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency);


PagedResult<RelationItem> GetPagedDescendantsInReferences(int parentId, long pageIndex, int pageSize, bool filterMustBeIsDependency);


PagedResult<RelationItem> GetPagedItemsWithRelations(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal static IUmbracoBuilder AddRepositories(this IUmbracoBuilder builder)
builder.Services.AddUnique<IPublicAccessRepository, PublicAccessRepository>();
builder.Services.AddUnique<IRedirectUrlRepository, RedirectUrlRepository>();
builder.Services.AddUnique<IRelationRepository, RelationRepository>();
builder.Services.AddUnique<ITrackedReferencesRepository, TrackedReferencesRepository>();
builder.Services.AddUnique<IRelationTypeRepository, RelationTypeRepository>();
builder.Services.AddUnique<IServerRegistrationRepository, ServerRegistrationRepository>();
builder.Services.AddUnique<ITagRepository, TagRepository>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal static IUmbracoBuilder AddServices(this IUmbracoBuilder builder)
builder.Services.AddUnique<IServerRegistrationService, ServerRegistrationService>();
builder.Services.AddUnique<IEntityService, EntityService>();
builder.Services.AddUnique<IRelationService, RelationService>();
builder.Services.AddUnique<ITrackedReferencesService, TrackedReferencesService>();
builder.Services.AddUnique<IMacroService, MacroService>();
builder.Services.AddUnique<IMemberTypeService, MemberTypeService>();
builder.Services.AddUnique<IMemberGroupService, MemberGroupService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Handle(ContentMovedToRecycleBinNotification notification)
var documentObjectType = Constants.ObjectTypes.Document;
const string relationTypeName = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName;

relationType = new RelationType(relationTypeName, relationTypeAlias, false, documentObjectType, documentObjectType);
relationType = new RelationType(relationTypeName, relationTypeAlias, false, documentObjectType, documentObjectType, false);
_relationService.Save(relationType);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public void Handle(MediaMovedToRecycleBinNotification notification)
{
var documentObjectType = Constants.ObjectTypes.Document;
const string relationTypeName = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName;
relationType = new RelationType(relationTypeName, relationTypeAlias, false, documentObjectType, documentObjectType);
relationType = new RelationType(relationTypeName, relationTypeAlias, false, documentObjectType, documentObjectType, false);
_relationService.Save(relationType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,21 +421,21 @@ void InsertDataTypeDto(int id, string editorAlias, string dbType, string configu

private void CreateRelationTypeData()
{
var relationType = new RelationTypeDto { Id = 1, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Document, ParentObjectType = Cms.Core.Constants.ObjectTypes.Document, Dual = true, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateDocumentOnCopyName };
var relationType = new RelationTypeDto { Id = 1, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Document, ParentObjectType = Cms.Core.Constants.ObjectTypes.Document, Dual = true, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateDocumentOnCopyName, IsDependency = false};
relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
_database.Insert(Cms.Core.Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
relationType = new RelationTypeDto { Id = 2, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Document, ParentObjectType = Cms.Core.Constants.ObjectTypes.Document, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName };
relationType = new RelationTypeDto { Id = 2, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Document, ParentObjectType = Cms.Core.Constants.ObjectTypes.Document, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName, IsDependency = false };
relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
_database.Insert(Cms.Core.Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
relationType = new RelationTypeDto { Id = 3, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Media, ParentObjectType = Cms.Core.Constants.ObjectTypes.Media, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName };
relationType = new RelationTypeDto { Id = 3, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias, ChildObjectType = Cms.Core.Constants.ObjectTypes.Media, ParentObjectType = Cms.Core.Constants.ObjectTypes.Media, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName, IsDependency = false };
relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
_database.Insert(Cms.Core.Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);

relationType = new RelationTypeDto { Id = 4, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelatedMediaAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelatedMediaName };
relationType = new RelationTypeDto { Id = 4, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelatedMediaAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelatedMediaName, IsDependency = true };
relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
_database.Insert(Cms.Core.Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);

relationType = new RelationTypeDto { Id = 5, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelatedDocumentAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelatedDocumentName };
relationType = new RelationTypeDto { Id = 5, Alias = Cms.Core.Constants.Conventions.RelationTypes.RelatedDocumentAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Cms.Core.Constants.Conventions.RelationTypes.RelatedDocumentName, IsDependency = true };
relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
_database.Insert(Cms.Core.Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ protected void DefinePlan()

// TO 9.4.0
To<AddScheduledPublishingLock>("{DBBA1EA0-25A1-4863-90FB-5D306FB6F1E1}");
To<UpdateRelationTypesToHandleDependencies>("{DED98755-4059-41BB-ADBD-3FEAB12D1D7B}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Linq;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Extensions;


namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_4_0
{
internal class UpdateRelationTypesToHandleDependencies : MigrationBase
{
public UpdateRelationTypesToHandleDependencies(IMigrationContext context)
: base(context)
{
}

protected override void Migrate()
{
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList();

AddColumnIfNotExists<RelationTypeDto>(columns, "isDependency");

var aliasesWithDependencies = new[]
{
Core.Constants.Conventions.RelationTypes.RelatedDocumentAlias,
Core.Constants.Conventions.RelationTypes.RelatedMediaAlias
};

Database.Execute(
Sql()
.Update<RelationTypeDto>(u => u.Set(x => x.IsDependency, true))
.WhereIn<RelationTypeDto>(x => x.Alias, aliasesWithDependencies));

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ internal class RelationTypeDto
[Length(100)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_umbracoRelationType_alias")]
public string Alias { get; set; }

[Constraint(Default = "0")]
[Column("isDependency")]
public bool IsDependency { get; set; }
}
}
Loading