From 5c56767b817447bb5e5d6ec664f07a2064e65bc2 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Sat, 27 Dec 2025 08:41:08 +1000 Subject: [PATCH] Rename DefaultCollectionOwner -> DefaultCollectionOwnerId --- src/Core/Entities/Collection.cs | 2 +- .../Repositories/CollectionRepository.cs | 2 +- .../CollectionEntityTypeConfiguration.cs | 6 +++--- .../Repositories/OrganizationUserRepository.cs | 2 +- .../Repositories/CollectionRepository.cs | 4 ++-- .../Collection_UpsertDefaultCollection.sql | 6 +++--- .../OrganizationUser_MigrateDefaultCollection.sql | 2 +- src/Sql/dbo/Tables/Collection.sql | 8 ++++---- .../OrganizationUserRepositoryTests.cs | 10 +++++----- ...tion_AddDefaultCollectionOwnerAndConstraint.sql | 14 +++++++------- ...12-20_01_Collection_UpsertDefaultCollection.sql | 6 +++--- ...2_OrganizationUser_MigrateDefaultCollection.sql | 4 ++-- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Core/Entities/Collection.cs b/src/Core/Entities/Collection.cs index 33f6935d3e..d156b3d121 100644 --- a/src/Core/Entities/Collection.cs +++ b/src/Core/Entities/Collection.cs @@ -66,7 +66,7 @@ public class Collection : ITableObject /// Only populated for collections of type DefaultUserCollection. /// Set to null when the OrganizationUser entry is deleted. /// - public Guid? DefaultCollectionOwner { get; set; } + public Guid? DefaultCollectionOwnerId { get; set; } public void SetNewId() { diff --git a/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs b/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs index 8e9156656a..bd5248bd58 100644 --- a/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs +++ b/src/Infrastructure.Dapper/Repositories/CollectionRepository.cs @@ -463,7 +463,7 @@ public class CollectionRepository : Repository, ICollectionRep RevisionDate = DateTime.UtcNow, Type = CollectionType.DefaultUserCollection, DefaultUserCollectionEmail = null, - DefaultCollectionOwner = orgUserId + DefaultCollectionOwnerId = orgUserId }); collectionUsers.Add(new CollectionUser diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs index aaa86b6573..6d20390740 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/CollectionEntityTypeConfiguration.cs @@ -13,17 +13,17 @@ public class CollectionEntityTypeConfiguration : IEntityTypeConfiguration new { c.DefaultCollectionOwner, c.OrganizationId, c.Type }) + .HasIndex(c => new { c.DefaultCollectionOwnerId, c.OrganizationId, c.Type }) .IsUnique() .HasFilter("[Type] = 1") - .HasDatabaseName("IX_Collection_DefaultCollectionOwner_OrganizationId_Type"); + .HasDatabaseName("IX_Collection_DefaultCollectionOwnerId_OrganizationId_Type"); // Configure FK with NO ACTION delete behavior to prevent cascade conflicts // Cleanup is handled explicitly in OrganizationUserRepository.DeleteAsync builder .HasOne() .WithMany() - .HasForeignKey(c => c.DefaultCollectionOwner) + .HasForeignKey(c => c.DefaultCollectionOwnerId) .OnDelete(DeleteBehavior.NoAction); builder.ToTable(nameof(Collection)); diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs index c8c453f224..0edd5e9ccd 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationUserRepository.cs @@ -115,7 +115,7 @@ public class OrganizationUserRepository : Repository c.RevisionDate, utcNow) .SetProperty(c => c.DefaultUserCollectionEmail, c => c.DefaultUserCollectionEmail == null ? email : c.DefaultUserCollectionEmail) - .SetProperty(c => c.DefaultCollectionOwner, (Guid?)null)); + .SetProperty(c => c.DefaultCollectionOwnerId, (Guid?)null)); await dbContext.CollectionUsers .Where(cu => cu.OrganizationUserId == organizationUser.Id) diff --git a/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs b/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs index bbb0de743b..e00fd8d7af 100644 --- a/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/CollectionRepository.cs @@ -842,7 +842,7 @@ public class CollectionRepository : Repository