mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Migrates persisted identifiers to GUID version 7.
This commit is contained in:
1 parent
fb92a38a7b
commit
8eba545b2b
80 files changed
+305
-129
No files matched your search
@@ -11,7 +11,10 @@ using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Themes;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.DataAccess.Common.ValueGeneration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Core.UoW;
|
||||
@@ -210,6 +213,14 @@ public class LuminaDbContext : DbContext
|
||||
// Find all the entity configurations in the assembly and apply them.
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(LuminaDbContext).Assembly);
|
||||
|
||||
// The relational provider seeds its Guid value generators from Guid.NewGuid, so replace them with a time ordered generator for every
|
||||
// identifier that the persistence layer assigns itself. This covers real keys, such as PermissionEntity.Id, and the shadow keys of
|
||||
// owned collections, such as AlbumReleaseTypes.Id.
|
||||
foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes())
|
||||
foreach (IMutableProperty property in entityType.GetProperties())
|
||||
if (property.ClrType == typeof(Guid) && property.ValueGenerated == ValueGenerated.OnAdd)
|
||||
property.SetValueGeneratorFactory((generatedProperty, declaringType) => new GuidV7ValueGenerator());
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user