Migrates persisted identifiers to GUID version 7.

This commit is contained in:
BinaryAlley committed 2026-11-16 22:22:51 +02:00
1 parent fb92a38a7b
commit 8eba545b2b
80 files changed
+305 -129

No files matched your search

@@ -66,7 +66,7 @@ public static class AlbumMapping
MusicBrainzReleaseArtistId = domainEntity.MusicBrainzReleaseArtistId.HasValue ? domainEntity.MusicBrainzReleaseArtistId.Value.Value : null,
Contributors = [.. domainEntity.Contributors.Select(contributor => new AlbumContributorEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
AlbumId = domainEntity.Id.Value,
MediaContributorId = contributor.ContributorId.Value,
Role = contributor.Role,
@@ -48,7 +48,7 @@ public static class ArtistMapping
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
Contributors = [.. domainEntity.Contributors.Select(contributor => new ArtistContributorEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
ArtistId = domainEntity.Id.Value,
MediaContributorId = contributor.ContributorId.Value,
Role = contributor.Role,
@@ -72,7 +72,7 @@ public static class TrackMapping
MusicBrainzWorkId = domainEntity.Work.HasValue ? domainEntity.Work.Value.MusicBrainzWorkId.Value : null,
Contributors = [.. domainEntity.Contributors.Select(contributor => new TrackContributorEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
TrackId = domainEntity.Id.Value,
MediaContributorId = contributor.ContributorId.Value,
Role = contributor.Role,
@@ -60,7 +60,7 @@ public static class BookMapping
ISBNs = [.. domainEntity.ISBNs.ToRepositoryEntities()],
Contributors = [.. domainEntity.Contributors.Select(contributor => new BookContributorEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
BookId = domainEntity.Id.Value,
MediaContributorId = contributor.ContributorId.Value,
Role = contributor.Role,
@@ -115,6 +115,6 @@ public static class BookMapping
entity.BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null;
entity.AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null;
entity.UpdatedOnUtc = DateTime.UtcNow;
entity.UpdatedBy = Guid.NewGuid();
entity.UpdatedBy = Guid.CreateVersion7();
}
}
@@ -29,7 +29,7 @@ public static class UpdateBookCoverCommandMapping
{
return new BookArtworkEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
BookId = bookId,
ArtworkType = ArtworkType.Cover,
Ordinal = 0,
@@ -97,7 +97,7 @@ public class SetupApplicationCommandHandler : ICommandHandler<SetupApplicationCo
return Errors.Authorization.AdminAccountAlreadyCreated;
// No users are present, register the admin one.
string? totpSecret = null;
Guid id = Guid.NewGuid();
Guid id = Guid.CreateVersion7();
UserEntity user = new()
{
Id = id,
@@ -158,7 +158,7 @@ public class SetupApplicationCommandHandler : ICommandHandler<SetupApplicationCo
return getScheduledJobsResult.Errors;
foreach (ScheduledJobEntity scheduledJob in getScheduledJobsResult.Value.Data)
if (scheduledJob.Status == ScheduledJobStatus.Active)
_domainEventsQueue.Enqueue(new ScheduledJobCycleStartedDomainEvent(Guid.NewGuid(), ScheduledJobId.Create(scheduledJob.Id), DateTime.UtcNow));
_domainEventsQueue.Enqueue(new ScheduledJobCycleStartedDomainEvent(Guid.CreateVersion7(), ScheduledJobId.Create(scheduledJob.Id), DateTime.UtcNow));
// TODO: insert the default admin profile preferences when they are implemented.
// If 2FA was enabled during registration, the TOTP secret needs to be delivered to the client unhashed, so it can be displayed.
@@ -101,7 +101,7 @@ public class AddPlaylistEntryCommandHandler : ICommandHandler<AddPlaylistEntryCo
if (!Playlist.CanContain(getPlaylistResult.Value.Type, PlaylistMediaItemType.MusicTrack))
return DomainErrors.Playlists.PlaylistDoesNotAcceptMediaItems;
Guid entryId = Guid.NewGuid();
Guid entryId = Guid.CreateVersion7();
DateTime updatedOnUtc = DateTime.UtcNow;
Result<PlaylistBulkAddResultDto> addEntryResult = await _unitOfWork.PlaylistRepository
.AddEntriesAsync(playlistId, userId, [trackId], PlaylistMediaItemType.MusicTrack, [entryId], updatedOnUtc, cancellationToken).ConfigureAwait(false);
@@ -67,7 +67,7 @@ public class UpdateSchedulerDisplayPreferencesCommandHandler : ICommandHandler<U
// Upsert the display preferences of the scheduler page of the current user.
SchedulerDisplayPreferencesEntity displayPreferences = new()
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
UserId = userId,
JobTypeFilter = command.JobTypeFilter,
DisplayTimeSpan = command.DisplayTimeSpan,
@@ -118,7 +118,7 @@ public class InstallThemeCommandHandler : ICommandHandler<InstallThemeCommand, R
{
themeEntity = new ThemeEntity
{
Id = Guid.NewGuid(),
Id = Guid.CreateVersion7(),
ThemeId = manifest.Id,
Name = manifest.Name,
Description = manifest.Description,
@@ -82,7 +82,7 @@ public class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, R
// Build the account, hashing the password and URI escaping it the same way as the stored form.
string? totpSecret = null;
Guid id = Guid.NewGuid();
Guid id = Guid.CreateVersion7();
UserEntity user = new()
{
Id = id,