mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Formats code comments as sentences in the production sources.
Capitalizes the first word and adds the terminal period across the domain, application, data access, infrastructure, API and web layers and the plugins. No comment is reworded. The change also normalizes the TODO bodies to lowercase, leaves commented-out code untouched, corrects the Threat/Treat typo and the dangling hyphen in the exception middleware, and collapses two accidental repeated terminal periods.
This commit is contained in:
1 parent
88455fec9c
commit
727aa33318
142 files changed
+403
-403
No files matched your search
@@ -142,8 +142,8 @@ public class AlbumConfiguration : IEntityTypeConfiguration<AlbumEntity>
|
||||
.HasForeignKey(album => album.ArtistId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key
|
||||
// Since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key.
|
||||
builder.HasMany(album => album.Tags)
|
||||
.WithMany()
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AlbumContributorConfiguration : IEntityTypeConfiguration<AlbumContr
|
||||
builder.ToTable("AlbumContributors");
|
||||
builder.HasKey(albumContributor => albumContributor.Id);
|
||||
builder.Property(albumContributor => albumContributor.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(albumContributor => albumContributor.AlbumId)
|
||||
@@ -35,7 +35,7 @@ public class AlbumContributorConfiguration : IEntityTypeConfiguration<AlbumContr
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(albumContributor => albumContributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ArtistConfiguration : IEntityTypeConfiguration<ArtistEntity>
|
||||
builder.ToTable("Artists");
|
||||
builder.HasKey(artist => artist.Id);
|
||||
builder.Property(artist => artist.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(artist => artist.LibraryId)
|
||||
@@ -143,8 +143,8 @@ public class ArtistConfiguration : IEntityTypeConfiguration<ArtistEntity>
|
||||
.HasMaxLength(20);
|
||||
});
|
||||
|
||||
// since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key
|
||||
// Since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key.
|
||||
builder.HasMany(artist => artist.Tags)
|
||||
.WithMany()
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ArtistContributorConfiguration : IEntityTypeConfiguration<ArtistCon
|
||||
builder.ToTable("ArtistContributors");
|
||||
builder.HasKey(artistContributor => artistContributor.Id);
|
||||
builder.Property(artistContributor => artistContributor.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(artistContributor => artistContributor.ArtistId)
|
||||
@@ -35,7 +35,7 @@ public class ArtistContributorConfiguration : IEntityTypeConfiguration<ArtistCon
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(artistContributor => artistContributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BookArtworkConfiguration : IEntityTypeConfiguration<BookArtworkEnti
|
||||
builder.ToTable("BookArtwork");
|
||||
builder.HasKey(bookArtwork => bookArtwork.Id);
|
||||
builder.Property(bookArtwork => bookArtwork.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(bookArtwork => bookArtwork.BookId)
|
||||
.IsRequired()
|
||||
@@ -49,7 +49,7 @@ public class BookArtworkConfiguration : IEntityTypeConfiguration<BookArtworkEnti
|
||||
builder.Property(bookArtwork => bookArtwork.LastUpdateUtc)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(bookArtwork => bookArtwork.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(9);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
builder.ToTable("Books");
|
||||
builder.HasKey(book => book.Id);
|
||||
builder.Property(book => book.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(book => book.Title)
|
||||
@@ -62,8 +62,8 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
.HasColumnOrder(14);
|
||||
builder.Property(book => book.OriginalLanguageNativeName)
|
||||
.HasColumnOrder(15);
|
||||
// since Tag is a Domain ValueObject (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure it as a many-to-many relationship, where the tag itself is the primary key
|
||||
// Since Tag is a Domain ValueObject (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure it as a many-to-many relationship, where the tag itself is the primary key.
|
||||
builder.HasMany(book => book.Tags)
|
||||
.WithMany()
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
@@ -213,7 +213,7 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(book => book.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(32);
|
||||
@@ -231,7 +231,7 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
.HasColumnOrder(35);
|
||||
|
||||
builder.HasIndex(book => new { book.LibraryId, book.Path })
|
||||
.IsUnique(); // the same physical book on disk cannot appear twice in the same library
|
||||
.IsUnique(); // The same physical book on disk cannot appear twice in the same library.
|
||||
builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus });
|
||||
// The deleted items page filters by library and deletion state, and orders by the stored deletion time, the title and the Id, so the
|
||||
// index follows the same order and no temporary B-tree is needed for the sort.
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BookContributorConfiguration : IEntityTypeConfiguration<BookContrib
|
||||
builder.ToTable("BookContributors");
|
||||
builder.HasKey(bookContributor => bookContributor.Id);
|
||||
builder.Property(bookContributor => bookContributor.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(bookContributor => bookContributor.BookId)
|
||||
@@ -35,7 +35,7 @@ public class BookContributorConfiguration : IEntityTypeConfiguration<BookContrib
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(bookContributor => bookContributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
@@ -18,10 +18,10 @@ public class DirectoryScanFingerprintConfiguration : IEntityTypeConfiguration<Di
|
||||
public void Configure(EntityTypeBuilder<DirectoryScanFingerprintEntity> builder)
|
||||
{
|
||||
builder.ToTable("DirectoryScanFingerprints");
|
||||
// composite key, so that each directory scan fingerprint is uniquely identified within its library by its path
|
||||
// Composite key, so that each directory scan fingerprint is uniquely identified within its library by its path.
|
||||
builder.HasKey(directoryScanFingerprint => new { directoryScanFingerprint.LibraryId, directoryScanFingerprint.Path });
|
||||
|
||||
// one library with many directory scan fingerprints
|
||||
// One library with many directory scan fingerprints.
|
||||
builder.HasOne<LibraryEntity>()
|
||||
.WithMany()
|
||||
.HasForeignKey(directoryScanFingerprint => directoryScanFingerprint.LibraryId)
|
||||
@@ -41,7 +41,7 @@ public class DirectoryScanFingerprintConfiguration : IEntityTypeConfiguration<Di
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
// enables fast lookups of the directory scan fingerprints of a library
|
||||
// Enables fast lookups of the directory scan fingerprints of a library.
|
||||
builder.HasIndex(directoryScanFingerprint => directoryScanFingerprint.LibraryId);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class FavoriteConfiguration : IEntityTypeConfiguration<FavoriteEntity>
|
||||
builder.ToTable("Favorites");
|
||||
builder.HasKey(favorite => favorite.Id);
|
||||
builder.Property(favorite => favorite.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// A favorite belongs to the user that created it, and it is removed with that user.
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ public class LibraryBookReaderConfigurationConfiguration : IEntityTypeConfigurat
|
||||
builder.ToTable("LibraryBookReaderConfigurations");
|
||||
builder.HasKey(configuration => configuration.Id);
|
||||
builder.Property(configuration => configuration.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(configuration => configuration.LibraryId)
|
||||
.IsRequired()
|
||||
@@ -32,7 +32,7 @@ public class LibraryBookReaderConfigurationConfiguration : IEntityTypeConfigurat
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(configuration => configuration.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
builder.ToTable("Libraries");
|
||||
builder.HasKey(library => library.Id);
|
||||
builder.Property(library => library.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(library => library.Title)
|
||||
@@ -83,19 +83,19 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(18);
|
||||
|
||||
// one user with many libraries
|
||||
// One user with many libraries.
|
||||
builder.HasOne(library => library.User)
|
||||
.WithMany(user => user.Libraries)
|
||||
.HasForeignKey(library => library.UserId)
|
||||
.IsRequired();
|
||||
|
||||
// one library with many scans
|
||||
// One library with many scans.
|
||||
builder.HasMany(library => library.LibraryScans)
|
||||
.WithOne(libraryScan => libraryScan.Library)
|
||||
.HasForeignKey(libraryScan => libraryScan.LibraryId)
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a library deletes library scans
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a library deletes library scans.
|
||||
|
||||
// using OwnsMany because paths are domain Value Objects, thus they have no independent identity, and their lifecycle is bound to the Library
|
||||
// Using OwnsMany because paths are domain Value Objects, thus they have no independent identity, and their lifecycle is bound to the Library.
|
||||
builder.OwnsMany(library => library.ContentLocations, contentLocationBuilder =>
|
||||
{
|
||||
contentLocationBuilder.ToTable("LibraryContentLocations");
|
||||
@@ -112,7 +112,7 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// the path template parts are ordered, so their position is stored explicitly and part of a unique index together with the library
|
||||
// The path template parts are ordered, so their position is stored explicitly and part of a unique index together with the library.
|
||||
builder.OwnsMany(library => library.PathTemplateParts, partBuilder =>
|
||||
{
|
||||
partBuilder.ToTable("LibraryPathTemplateParts");
|
||||
@@ -139,7 +139,7 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(library => library.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(12);
|
||||
|
||||
@@ -21,16 +21,16 @@ public class LibraryScanConfiguration : IEntityTypeConfiguration<LibraryScanEnti
|
||||
builder.ToTable("LibraryScans");
|
||||
builder.HasKey(library => library.Id);
|
||||
builder.Property(library => library.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// one user with many library scans
|
||||
// One user with many library scans.
|
||||
builder.HasOne(libraryScan => libraryScan.User)
|
||||
.WithMany(user => user.LibraryScans)
|
||||
.HasForeignKey(libraryScan => libraryScan.UserId)
|
||||
.IsRequired();
|
||||
|
||||
// one library with many library scans
|
||||
// One library with many library scans.
|
||||
builder.HasOne(libraryScan => libraryScan.Library)
|
||||
.WithMany(library => library.LibraryScans)
|
||||
.HasForeignKey(libraryScan => libraryScan.LibraryId)
|
||||
@@ -41,7 +41,7 @@ public class LibraryScanConfiguration : IEntityTypeConfiguration<LibraryScanEnti
|
||||
.HasConversion<string>()
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(libraryScan => libraryScan.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
@@ -58,10 +58,10 @@ public class LibraryScanConfiguration : IEntityTypeConfiguration<LibraryScanEnti
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
// Indexes
|
||||
// Indexes.
|
||||
|
||||
// enables fast lookup of latest non-running scans per library
|
||||
// Enables fast lookup of latest non-running scans per library.
|
||||
builder.HasIndex(libraryScan => new { libraryScan.LibraryId, libraryScan.Status, libraryScan.CreatedOnUtc })
|
||||
.IsDescending(true, false, true); // CreatedOnUtc DESC
|
||||
.IsDescending(true, false, true); // CreatedOnUtc DESC.
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,10 @@ public class LibraryScanResultConfiguration : IEntityTypeConfiguration<LibrarySc
|
||||
public void Configure(EntityTypeBuilder<LibraryScanResultEntity> builder)
|
||||
{
|
||||
builder.ToTable("LibraryScanResults");
|
||||
// composite key for efficient scan-specific lookups (paths are enforced as UNIQUE within the same scan)
|
||||
// Composite key for efficient scan-specific lookups (paths are enforced as UNIQUE within the same scan).
|
||||
builder.HasKey(libraryScanResult => new { libraryScanResult.LibraryScanId, libraryScanResult.Path });
|
||||
|
||||
// one library scan with many library scan results
|
||||
// One library scan with many library scan results.
|
||||
builder.HasOne(libraryScanResult => libraryScanResult.LibraryScan)
|
||||
.WithMany(libraryScan => libraryScan.LibraryScanResults)
|
||||
.HasForeignKey(libraryScanResult => libraryScanResult.LibraryScanId)
|
||||
@@ -38,7 +38,7 @@ public class LibraryScanResultConfiguration : IEntityTypeConfiguration<LibrarySc
|
||||
.HasColumnOrder(1);
|
||||
|
||||
builder.Property(libraryScanResult => libraryScanResult.ContentHash)
|
||||
.HasMaxLength(24) // xxHash128 as Base64
|
||||
.HasMaxLength(24) // xxHash128 as Base64.
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class LibraryScanResultConfiguration : IEntityTypeConfiguration<LibrarySc
|
||||
.HasMaxLength(10)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
// Indexes
|
||||
// Indexes.
|
||||
builder.HasIndex(libraryScanResult => new { libraryScanResult.ContentHash, libraryScanResult.FileSize, libraryScanResult.Path });
|
||||
|
||||
builder.HasIndex(libraryScanResult => libraryScanResult.Path);
|
||||
|
||||
@@ -18,10 +18,10 @@ public class LibraryScanSnapshotConfiguration : IEntityTypeConfiguration<Library
|
||||
public void Configure(EntityTypeBuilder<LibraryScanSnapshotEntity> builder)
|
||||
{
|
||||
builder.ToTable("LibraryScanSnapshots");
|
||||
// composite key, so that each media library scan snapshot item is uniquely identified within its library by its path
|
||||
// Composite key, so that each media library scan snapshot item is uniquely identified within its library by its path.
|
||||
builder.HasKey(libraryScanSnapshot => new { libraryScanSnapshot.LibraryId, libraryScanSnapshot.Path });
|
||||
|
||||
// one library with many media library scan snapshot items
|
||||
// One library with many media library scan snapshot items.
|
||||
builder.HasOne(libraryScanSnapshot => libraryScanSnapshot.Library)
|
||||
.WithMany()
|
||||
.HasForeignKey(libraryScanSnapshot => libraryScanSnapshot.LibraryId)
|
||||
@@ -49,7 +49,7 @@ public class LibraryScanSnapshotConfiguration : IEntityTypeConfiguration<Library
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(libraryScanSnapshot => libraryScanSnapshot.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
@@ -66,7 +66,7 @@ public class LibraryScanSnapshotConfiguration : IEntityTypeConfiguration<Library
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
// enables fast lookups of the media library scan snapshot items of a library
|
||||
// Enables fast lookups of the media library scan snapshot items of a library.
|
||||
builder.HasIndex(libraryScanSnapshot => libraryScanSnapshot.LibraryId);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -18,10 +18,10 @@ public class LibraryScanStagingResultsConfiguration : IEntityTypeConfiguration<L
|
||||
public void Configure(EntityTypeBuilder<LibraryScanStagingResultsEntity> builder)
|
||||
{
|
||||
builder.ToTable("LibraryScanStagingResults");
|
||||
// composite key, so that each media library scan staging result is uniquely identified within its scan by its path
|
||||
// Composite key, so that each media library scan staging result is uniquely identified within its scan by its path.
|
||||
builder.HasKey(libraryScanStagingResult => new { libraryScanStagingResult.LibraryScanId, libraryScanStagingResult.Path });
|
||||
|
||||
// one media library scan with many media library scan staging results
|
||||
// One media library scan with many media library scan staging results.
|
||||
builder.HasOne<LibraryScanEntity>()
|
||||
.WithMany()
|
||||
.HasForeignKey(libraryScanStagingResult => libraryScanStagingResult.LibraryScanId)
|
||||
@@ -61,7 +61,7 @@ public class LibraryScanStagingResultsConfiguration : IEntityTypeConfiguration<L
|
||||
.IsRequired()
|
||||
.HasColumnOrder(7);
|
||||
|
||||
// enables fast lookups of the staging results of a scan that need their content hashed
|
||||
// Enables fast lookups of the staging results of a scan that need their content hashed.
|
||||
builder.HasIndex(libraryScanStagingResult => new { libraryScanStagingResult.LibraryScanId, libraryScanStagingResult.NeedsRehash });
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class MediaConsumptionRecordConfiguration : IEntityTypeConfiguration<Medi
|
||||
builder.ToTable("MediaConsumptionRecords");
|
||||
builder.HasKey(record => record.Id);
|
||||
builder.Property(record => record.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// A consumption record belongs to the user that started it, and it is removed with that user.
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MediaContributorConfiguration : IEntityTypeConfiguration<MediaContr
|
||||
builder.ToTable("MediaContributors");
|
||||
builder.HasKey(contributor => contributor.Id);
|
||||
builder.Property(contributor => contributor.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(contributor => contributor.DisplayName)
|
||||
.IsRequired()
|
||||
@@ -38,7 +38,7 @@ public class MediaContributorConfiguration : IEntityTypeConfiguration<MediaContr
|
||||
builder.Property(contributor => contributor.DateOfDeath)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(contributor => contributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class MediaResumePointConfiguration : IEntityTypeConfiguration<MediaResum
|
||||
builder.ToTable("MediaResumePoints");
|
||||
builder.HasKey(resumePoint => resumePoint.Id);
|
||||
builder.Property(resumePoint => resumePoint.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// A resume point belongs to the user that owns it, and it is removed with that user.
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MusicArtworkConfiguration : IEntityTypeConfiguration<MusicArtworkEn
|
||||
builder.ToTable("MusicArtwork");
|
||||
builder.HasKey(musicArtwork => musicArtwork.Id);
|
||||
builder.Property(musicArtwork => musicArtwork.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(musicArtwork => musicArtwork.OwnerType)
|
||||
.IsRequired()
|
||||
@@ -54,7 +54,7 @@ public class MusicArtworkConfiguration : IEntityTypeConfiguration<MusicArtworkEn
|
||||
builder.Property(musicArtwork => musicArtwork.LastUpdateUtc)
|
||||
.HasColumnOrder(9);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(musicArtwork => musicArtwork.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(10);
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ public class MusicLibraryScanItemMetadataConfiguration : IEntityTypeConfiguratio
|
||||
builder.ToTable("MusicLibraryScanItemMetadata");
|
||||
builder.HasKey(musicMetadata => musicMetadata.Id);
|
||||
builder.Property(musicMetadata => musicMetadata.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(musicMetadata => musicMetadata.LibraryScanId)
|
||||
.IsRequired()
|
||||
@@ -103,6 +103,6 @@ public class MusicLibraryScanItemMetadataConfiguration : IEntityTypeConfiguratio
|
||||
.HasColumnOrder(31);
|
||||
|
||||
builder.HasIndex(musicMetadata => new { musicMetadata.LibraryScanId, musicMetadata.Path })
|
||||
.IsUnique(); // the metadata of the same physical file cannot be staged twice during the same scan
|
||||
.IsUnique(); // The metadata of the same physical file cannot be staged twice during the same scan.
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class PermissionConfiguration : IEntityTypeConfiguration<PermissionEntity
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(permission => permission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PlaylistConfiguration : IEntityTypeConfiguration<PlaylistEntity>
|
||||
builder.ToTable("Playlists");
|
||||
builder.HasKey(playlist => playlist.Id);
|
||||
builder.Property(playlist => playlist.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// A playlist belongs to the user that created it, and it is removed with that user.
|
||||
|
||||
@@ -20,7 +20,7 @@ public class PluginConfiguration : IEntityTypeConfiguration<PluginEntity>
|
||||
builder.ToTable("Plugins");
|
||||
builder.HasKey(plugin => plugin.Id);
|
||||
builder.Property(plugin => plugin.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(plugin => plugin.Name)
|
||||
.IsRequired()
|
||||
@@ -51,7 +51,7 @@ public class PluginConfiguration : IEntityTypeConfiguration<PluginEntity>
|
||||
.IsRequired()
|
||||
.HasColumnOrder(8);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(plugin => plugin.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(9);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class RoleConfiguration : IEntityTypeConfiguration<RoleEntity>
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(1);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(role => role.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
@@ -19,26 +19,26 @@ public class RolePermissionConfiguration : IEntityTypeConfiguration<RolePermissi
|
||||
{
|
||||
builder.ToTable("RolePermissions");
|
||||
|
||||
// composite primary key
|
||||
// Composite primary key.
|
||||
builder.HasKey(rolePermission => new { rolePermission.RoleId, rolePermission.PermissionId });
|
||||
|
||||
builder.Ignore(rolePermission => rolePermission.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id
|
||||
builder.Ignore(rolePermission => rolePermission.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id.
|
||||
|
||||
// foreign key: Role
|
||||
// Foreign key: Role.
|
||||
builder.HasOne(rolePermission => rolePermission.Role)
|
||||
.WithMany(user => user.RolePermissions)
|
||||
.HasForeignKey(rolePermission => rolePermission.RoleId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Role deletes associated RolePermission
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a Role deletes associated RolePermission.
|
||||
|
||||
// foreign key: Permission
|
||||
// Foreign key: Permission.
|
||||
builder.HasOne(rolePermission => rolePermission.Permission)
|
||||
.WithMany(role => role.RolePermissions)
|
||||
.HasForeignKey(rolePermission => rolePermission.PermissionId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Permission deletes associated RolePermission
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a Permission deletes associated RolePermission.
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(rolePermission => rolePermission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
@@ -55,7 +55,7 @@ public class RolePermissionConfiguration : IEntityTypeConfiguration<RolePermissi
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
// Indexes.
|
||||
builder.HasIndex(userRole => new { userRole.RoleId, userRole.PermissionId })
|
||||
.IsUnique();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ScheduledJobConfiguration : IEntityTypeConfiguration<ScheduledJobEn
|
||||
builder.ToTable("ScheduledJobs");
|
||||
builder.HasKey(scheduledJob => scheduledJob.Id);
|
||||
builder.Property(scheduledJob => scheduledJob.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(scheduledJob => scheduledJob.Name)
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class SchedulerDisplayPreferencesConfiguration : IEntityTypeConfiguration
|
||||
builder.ToTable("SchedulerDisplayPreferences");
|
||||
builder.HasKey(preferences => preferences.Id);
|
||||
builder.Property(preferences => preferences.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(preferences => preferences.UserId)
|
||||
|
||||
@@ -21,10 +21,10 @@ public class ThemeConfiguration : IEntityTypeConfiguration<ThemeEntity>
|
||||
builder.ToTable("Themes");
|
||||
builder.HasKey(theme => theme.Id);
|
||||
builder.Property(theme => theme.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the install, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the install, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// the manifest id is the business key used by the clients, so it must be unique
|
||||
// The manifest id is the business key used by the clients, so it must be unique.
|
||||
builder.HasIndex(theme => theme.ThemeId)
|
||||
.IsUnique();
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ThemeConfiguration : IEntityTypeConfiguration<ThemeEntity>
|
||||
.HasConversion<string>()
|
||||
.HasColumnOrder(7);
|
||||
|
||||
// at most one theme can be current: the filtered unique index guarantees it at the database level, since every row that is not current has a null value here, and nulls are allowed to repeat
|
||||
// At most one theme can be current: the filtered unique index guarantees it at the database level, since every row that is not current has a null value here, and nulls are allowed to repeat.
|
||||
builder.HasIndex(theme => theme.IsCurrent)
|
||||
.IsUnique()
|
||||
.HasFilter("IsCurrent = 1");
|
||||
@@ -80,7 +80,7 @@ public class ThemeConfiguration : IEntityTypeConfiguration<ThemeEntity>
|
||||
.IsRequired()
|
||||
.HasColumnOrder(10);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(theme => theme.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(11);
|
||||
|
||||
@@ -167,8 +167,8 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
|
||||
.HasForeignKey(track => track.AlbumId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key
|
||||
// Since Tag and Genre are Domain ValueObjects (no identity), but we also don't want to have duplicates,
|
||||
// we need to configure them as many-to-many relationships, where the tag/genre itself is the primary key.
|
||||
builder.HasMany(track => track.Tags)
|
||||
.WithMany()
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
@@ -296,7 +296,7 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
|
||||
|
||||
builder.HasIndex(track => new { track.AlbumId, track.TrackNumber });
|
||||
builder.HasIndex(track => new { track.LibraryId, track.Path })
|
||||
.IsUnique(); // the same physical track file cannot appear twice in the same library
|
||||
.IsUnique(); // The same physical track file cannot appear twice in the same library.
|
||||
// The deleted items page filters by library and deletion state, and orders by the stored deletion time, the title and the Id, so the
|
||||
// filtered index follows the same order and no temporary B-tree is needed for the sort, while visible rows add no entries to it.
|
||||
builder.HasIndex(track => new { track.LibraryId, track.IsDeleted, track.DeletedOnUtc, track.Title, track.Id })
|
||||
|
||||
@@ -20,7 +20,7 @@ public class TrackContributorConfiguration : IEntityTypeConfiguration<TrackContr
|
||||
builder.ToTable("TrackContributors");
|
||||
builder.HasKey(trackContributor => trackContributor.Id);
|
||||
builder.Property(trackContributor => trackContributor.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(trackContributor => trackContributor.TrackId)
|
||||
@@ -35,7 +35,7 @@ public class TrackContributorConfiguration : IEntityTypeConfiguration<TrackContr
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(trackContributor => trackContributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class UserConfiguration : IEntityTypeConfiguration<UserEntity>
|
||||
builder.ToTable("Users");
|
||||
builder.HasKey(user => user.Id);
|
||||
builder.Property(user => user.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(user => user.Username)
|
||||
@@ -45,11 +45,11 @@ public class UserConfiguration : IEntityTypeConfiguration<UserEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
// relationships
|
||||
// Relationships.
|
||||
builder.HasMany(user => user.Libraries)
|
||||
.WithOne(library => library.User)
|
||||
.HasForeignKey(library => library.UserId)
|
||||
.IsRequired() // a library must have a user
|
||||
.IsRequired() // A library must have a user.
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasOne(user => user.UserRole)
|
||||
@@ -63,7 +63,7 @@ public class UserConfiguration : IEntityTypeConfiguration<UserEntity>
|
||||
.HasForeignKey(userPermission => userPermission.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(user => user.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
@@ -80,8 +80,8 @@ public class UserConfiguration : IEntityTypeConfiguration<UserEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(9);
|
||||
|
||||
// indexes
|
||||
// Indexes.
|
||||
builder.HasIndex(user => user.Username)
|
||||
.IsUnique(); // queried frequently
|
||||
.IsUnique(); // Queried frequently.
|
||||
}
|
||||
}
|
||||
@@ -19,26 +19,26 @@ public class UserPermissionConfiguration : IEntityTypeConfiguration<UserPermissi
|
||||
{
|
||||
builder.ToTable("UserPermissions");
|
||||
|
||||
// composite primary key
|
||||
// Composite primary key.
|
||||
builder.HasKey(userPermission => new { userPermission.UserId, userPermission.PermissionId });
|
||||
|
||||
builder.Ignore(userPermission => userPermission.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id
|
||||
builder.Ignore(userPermission => userPermission.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id.
|
||||
|
||||
// foreign key: User
|
||||
// Foreign key: User.
|
||||
builder.HasOne(userPermission => userPermission.User)
|
||||
.WithMany(user => user.UserPermissions)
|
||||
.HasForeignKey(userPermission => userPermission.UserId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a User deletes associated UserPermissions
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a User deletes associated UserPermissions.
|
||||
|
||||
// foreign key: Permission
|
||||
// Foreign key: Permission.
|
||||
builder.HasOne(userPermission => userPermission.Permission)
|
||||
.WithMany(role => role.UserPermissions)
|
||||
.HasForeignKey(userPermission => userPermission.PermissionId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Permission deletes associated UserPermissions
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a Permission deletes associated UserPermissions.
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(userPermission => userPermission.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
@@ -55,7 +55,7 @@ public class UserPermissionConfiguration : IEntityTypeConfiguration<UserPermissi
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
// Indexes.
|
||||
builder.HasIndex(userRole => new { userRole.UserId, userRole.PermissionId })
|
||||
.IsUnique();
|
||||
}
|
||||
|
||||
@@ -19,26 +19,26 @@ public class UserRoleConfiguration : IEntityTypeConfiguration<UserRoleEntity>
|
||||
{
|
||||
builder.ToTable("UserRoles");
|
||||
|
||||
// primary key
|
||||
// Primary key.
|
||||
builder.HasKey(userRole => userRole.UserId );
|
||||
|
||||
builder.Ignore(userRole => userRole.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id
|
||||
builder.Ignore(userRole => userRole.Id); // Id is only needed as a generic constraint for the repository, but this entity uses a composite key as Id.
|
||||
|
||||
// foreign key: User (one-to-one relationship)
|
||||
// Foreign key: User (one-to-one relationship).
|
||||
builder.HasOne(userRole => userRole.User)
|
||||
.WithOne(user => user.UserRole)
|
||||
.HasForeignKey<UserRoleEntity>(userRole => userRole.UserId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a User deletes associated UserRole
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a User deletes associated UserRole.
|
||||
|
||||
// foreign key: Role (many-to-one relationship)
|
||||
// Foreign key: Role (many-to-one relationship).
|
||||
builder.HasOne(userRole => userRole.Role)
|
||||
.WithMany(role => role.UserRoles)
|
||||
.HasForeignKey(userRole => userRole.RoleId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Cascade); // deleting a Role deletes associated UserRoles
|
||||
.OnDelete(DeleteBehavior.Cascade); // Deleting a Role deletes associated UserRoles.
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(userRole => userRole.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
@@ -55,7 +55,7 @@ public class UserRoleConfiguration : IEntityTypeConfiguration<UserRoleEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// indexes
|
||||
// Indexes.
|
||||
builder.HasIndex(userRole => new { userRole.UserId, userRole.RoleId })
|
||||
.IsUnique();
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
|
||||
builder.ToTable("UserSettings");
|
||||
builder.HasKey(settings => settings.Id);
|
||||
builder.Property(settings => settings.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.ValueGeneratedNever() // Because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it.
|
||||
.HasColumnOrder(0);
|
||||
|
||||
// one user with one set of settings
|
||||
// One user with one set of settings.
|
||||
builder.HasOne<UserEntity>()
|
||||
.WithOne()
|
||||
.HasForeignKey<UserSettingsEntity>(settings => settings.UserId)
|
||||
@@ -130,7 +130,7 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
|
||||
.IsRequired()
|
||||
.HasColumnOrder(29);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(settings => settings.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
@@ -147,7 +147,7 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
// one user can have at most one set of settings
|
||||
// One user can have at most one set of settings.
|
||||
builder.HasIndex(settings => settings.UserId)
|
||||
.IsUnique();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Reflection;
|
||||
namespace Lumina.DataAccess.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Utility class for registering the services of the Data Access layer into the Dependency Injection container..
|
||||
/// Utility class for registering the services of the Data Access layer into the Dependency Injection container.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class DataAccessLayerServices
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class UpdateAuditableEntitiesInterceptor : SaveChangesInterceptor
|
||||
Guid? userId = _currentUserService.UserId;
|
||||
DateTime utcNow = _dateTimeProvider.UtcNow;
|
||||
|
||||
// retrieve all entities implementing IAuditableEntity that are being tracked and have either Added or Modified state
|
||||
// Retrieve all entities implementing IAuditableEntity that are being tracked and have either Added or Modified state.
|
||||
foreach (EntityEntry<IAuditableEntity> entry in context.ChangeTracker.Entries<IAuditableEntity>())
|
||||
{
|
||||
if (entry.State == EntityState.Added)
|
||||
@@ -100,12 +100,12 @@ public sealed class UpdateAuditableEntitiesInterceptor : SaveChangesInterceptor
|
||||
/// <param name="utcNow">The current UTC timestamp.</param>
|
||||
private static void SetModificationProperties(EntityEntry<IAuditableEntity> entry, Guid? userId, DateTime utcNow)
|
||||
{
|
||||
// prevent modification of creation properties
|
||||
// Prevent modification of creation properties.
|
||||
entry.Property(auditableEntity => auditableEntity.CreatedOnUtc).IsModified = false;
|
||||
entry.Property(auditableEntity => auditableEntity.CreatedBy).IsModified = false;
|
||||
|
||||
// set modification properties
|
||||
// Set modification properties.
|
||||
entry.Entity.UpdatedOnUtc = utcNow;
|
||||
entry.Entity.UpdatedBy = userId ?? Guid.Parse("11111111-1111-1111-1111-111111111111"); // "SYSTEM" user Id
|
||||
entry.Entity.UpdatedBy = userId ?? Guid.Parse("11111111-1111-1111-1111-111111111111"); // "SYSTEM" user Id.
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -98,8 +98,8 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
// backfill the artwork of the books that already had a cover, so that the stored covers are preserved as enriched cover artwork
|
||||
// before the CoverImagePath column is dropped
|
||||
// Backfill the artwork of the books that already had a cover, so that the stored covers are preserved as enriched cover artwork
|
||||
// before the CoverImagePath column is dropped.
|
||||
migrationBuilder.Sql("""
|
||||
INSERT INTO BookArtwork (Id, BookId, ArtworkType, Ordinal, FileName, ContentHash, Status, Provider, LastUpdateUtc, CreatedOnUtc, CreatedBy, UpdatedOnUtc, UpdatedBy)
|
||||
SELECT lower(hex(randomblob(16))), Id, 'Cover', 0, CoverImagePath, 0, 'Enriched', NULL, NULL, datetime('now'), '00000000-0000-0000-0000-000000000000', NULL, NULL
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ namespace Lumina.DataAccess.Core.Repositories.Libraries;
|
||||
/// </summary>
|
||||
internal sealed class DirectoryScanFingerprintRepository : IDirectoryScanFingerprintRepository
|
||||
{
|
||||
private const int UPSERT_BATCH_SIZE = 500; // keeps the number of bound parameters of a single UPSERT statement well under the SQLite parameter limit
|
||||
private const int UPSERT_BATCH_SIZE = 500; // Keeps the number of bound parameters of a single UPSERT statement well under the SQLite parameter limit.
|
||||
private readonly LuminaDbContext _luminaDbContext;
|
||||
|
||||
/// <summary>
|
||||
@@ -63,14 +63,14 @@ internal sealed class DirectoryScanFingerprintRepository : IDirectoryScanFingerp
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Updated>> UpsertRangeAsync(IReadOnlyCollection<DirectoryScanFingerprintEntity> entities, CancellationToken cancellationToken)
|
||||
{
|
||||
// nothing to upsert for an empty collection
|
||||
// Nothing to upsert for an empty collection.
|
||||
if (entities.Count == 0)
|
||||
return Result.Updated;
|
||||
|
||||
await using SqliteConnection connection = await OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using DbTransaction transaction = await connection.BeginTransactionAsync(cancellationToken);
|
||||
List<DirectoryScanFingerprintEntity> remainingEntities = [.. entities];
|
||||
// upsert the entities in batches, to keep the number of bound parameters of a single UPSERT statement under the SQLite parameter limit
|
||||
// Upsert the entities in batches, to keep the number of bound parameters of a single UPSERT statement under the SQLite parameter limit.
|
||||
while (remainingEntities.Count > 0)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -103,10 +103,10 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
|
||||
DateTime nowUtc = DateTime.UtcNow;
|
||||
object parameters = new { libraryId, scanId, userId, nowUtc };
|
||||
|
||||
// the Id of the inserted rows is generated in SQL as a random 16 byte value formatted as upper case hex (hex(randomblob(16))), which the storage layer parses as a Guid;
|
||||
// generating the Ids in code would defeat the purpose of these single statement bulk inserts
|
||||
// The Id of the inserted rows is generated in SQL as a random 16 byte value formatted as upper case hex (hex(randomblob(16))), which the storage layer parses as a Guid;
|
||||
// generating the Ids in code would defeat the purpose of these single statement bulk inserts.
|
||||
|
||||
// add an audit entry for every media library scan snapshot item that is no longer present in the current scan, meaning it was deleted from the storage medium
|
||||
// Add an audit entry for every media library scan snapshot item that is no longer present in the current scan, meaning it was deleted from the storage medium.
|
||||
const string AUDIT_DELETED_SQL = """
|
||||
INSERT INTO LibraryScanResults (Id, LibraryScanId, Status, Path, ContentHash, FileSize, Ticks)
|
||||
SELECT hex(randomblob(16)), @scanId, 'Deleted', snapshot.Path, snapshot.ContentHash, snapshot.FileSize, snapshot.Ticks
|
||||
@@ -124,7 +124,7 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
|
||||
|
||||
await connection.ExecuteAsync(command).ConfigureAwait(false);
|
||||
|
||||
// add an audit entry for every new or changed media library scan staging result
|
||||
// Add an audit entry for every new or changed media library scan staging result.
|
||||
const string AUDIT_CHANGED_SQL = """
|
||||
INSERT INTO LibraryScanResults (Id, LibraryScanId, Status, Path, ContentHash, FileSize, Ticks)
|
||||
SELECT hex(randomblob(16)), @scanId, CASE WHEN staging.IsNew = 1 THEN 'New' ELSE 'Modified' END, staging.Path, staging.ContentHash, staging.Size, staging.Ticks
|
||||
@@ -137,7 +137,7 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
|
||||
|
||||
await connection.ExecuteAsync(command).ConfigureAwait(false);
|
||||
|
||||
// delete the media library scan snapshot items that are no longer present in the current scan, meaning they were deleted from the storage medium
|
||||
// Delete the media library scan snapshot items that are no longer present in the current scan, meaning they were deleted from the storage medium.
|
||||
const string DELETE_MISSING_SQL = """
|
||||
DELETE FROM LibraryScanSnapshots
|
||||
WHERE LibraryId = @libraryId
|
||||
@@ -153,7 +153,7 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
|
||||
|
||||
await connection.ExecuteAsync(command).ConfigureAwait(false);
|
||||
|
||||
// upsert the new and changed media library scan staging results into the media library scan snapshot
|
||||
// Upsert the new and changed media library scan staging results into the media library scan snapshot.
|
||||
const string UPSERT_SQL = """
|
||||
INSERT INTO LibraryScanSnapshots (Id, LibraryId, Path, ContentHash, FileSize, Ticks, CreatedOnUtc, CreatedBy, UpdatedOnUtc, UpdatedBy)
|
||||
SELECT hex(randomblob(16)), @libraryId, staging.Path, staging.ContentHash, staging.Size, staging.Ticks, @nowUtc, @userId, NULL, NULL
|
||||
@@ -172,7 +172,7 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
|
||||
|
||||
await connection.ExecuteAsync(command).ConfigureAwait(false);
|
||||
|
||||
// clear the staging results of the current scan, as they have been fully applied to the media library scan snapshot
|
||||
// Clear the staging results of the current scan, as they have been fully applied to the media library scan snapshot.
|
||||
const string CLEAR_STAGING_SQL = "DELETE FROM LibraryScanStagingResults WHERE LibraryScanId = @scanId;";
|
||||
|
||||
command = new(CLEAR_STAGING_SQL, parameters, transaction);
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@ namespace Lumina.DataAccess.Core.Repositories.Libraries;
|
||||
/// </summary>
|
||||
internal sealed class LibraryScanStagingResultsRepository : ILibraryScanStagingResultsRepository
|
||||
{
|
||||
private const int INSERT_BATCH_SIZE = 500; // keeps the number of bound parameters of a single INSERT statement well under the SQLite parameter limit
|
||||
private const int INSERT_BATCH_SIZE = 500; // Keeps the number of bound parameters of a single INSERT statement well under the SQLite parameter limit.
|
||||
private readonly LuminaDbContext _luminaDbContext;
|
||||
|
||||
/// <summary>
|
||||
@@ -43,14 +43,14 @@ internal sealed class LibraryScanStagingResultsRepository : ILibraryScanStagingR
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Created>> InsertRangeAsync(IReadOnlyCollection<LibraryScanStagingResultsEntity> entities, CancellationToken cancellationToken)
|
||||
{
|
||||
// nothing to insert for an empty collection
|
||||
// Nothing to insert for an empty collection.
|
||||
if (entities.Count == 0)
|
||||
return Result.Created;
|
||||
|
||||
await using SqliteConnection connection = await OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
|
||||
await using DbTransaction transaction = await connection.BeginTransactionAsync(cancellationToken);
|
||||
List<LibraryScanStagingResultsEntity> remainingEntities = [.. entities];
|
||||
// insert the entities in batches, to keep the number of bound parameters of a single INSERT statement under the SQLite parameter limit
|
||||
// Insert the entities in batches, to keep the number of bound parameters of a single INSERT statement under the SQLite parameter limit.
|
||||
while (remainingEntities.Count > 0)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -73,8 +73,8 @@ internal sealed class LibraryScanStagingResultsRepository : ILibraryScanStagingR
|
||||
public async Task<Result<Updated>> MarkChangesAgainstSnapshotAsync(Guid scanId, Guid libraryId, CancellationToken cancellationToken)
|
||||
{
|
||||
await using SqliteConnection connection = await OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
|
||||
// compare the discovered file system items against the media library scan snapshot of the previous scan, entirely in the database, so that the snapshot never needs to be loaded into memory:
|
||||
// an item with no snapshot entry is new, an item with the same size and last write time is unchanged and keeps the stored hash, and everything else changed and needs its content hashed again
|
||||
// Compare the discovered file system items against the media library scan snapshot of the previous scan, entirely in the database, so that the snapshot never needs to be loaded into memory:
|
||||
// An item with no snapshot entry is new, an item with the same size and last write time is unchanged and keeps the stored hash, and everything else changed and needs its content hashed again.
|
||||
const string MARK_CHANGES_SQL = """
|
||||
UPDATE LibraryScanStagingResults AS staging
|
||||
SET ContentHash = COALESCE(snapshot.ContentHash, 0),
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ internal sealed class MediaContributorRepository : IMediaContributorRepository
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the existing or newly created <see cref="MediaContributorEntity"/>, or an error.</returns>
|
||||
public async Task<Result<MediaContributorEntity>> FindOrCreateByDisplayNameAsync(string displayName, string? legalName, CancellationToken cancellationToken)
|
||||
{
|
||||
// the comparison is case-insensitive, so that "Stephen King" and "stephen king" are never treated as distinct contributors
|
||||
// The comparison is case-insensitive, so that "Stephen King" and "stephen king" are never treated as distinct contributors.
|
||||
string normalizedDisplayName = displayName.ToLowerInvariant();
|
||||
|
||||
// Contributors added earlier in the same unit of work are not returned by a database query, so the change tracker is consulted
|
||||
|
||||
@@ -997,7 +997,7 @@ internal sealed class PlaylistRepository : IPlaylistRepository
|
||||
/// <returns><see langword="true"/> for a unique constraint violation, <see langword="false"/> otherwise.</returns>
|
||||
private static bool IsUniqueConstraintViolation(SqliteException exception)
|
||||
{
|
||||
return exception.SqliteExtendedErrorCode == 2067; // SQLITE_CONSTRAINT_UNIQUE
|
||||
return exception.SqliteExtendedErrorCode == 2067; // SQLITE_CONSTRAINT_UNIQUE.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1007,7 +1007,7 @@ internal sealed class PlaylistRepository : IPlaylistRepository
|
||||
/// <returns><see langword="true"/> for a busy or locked database, <see langword="false"/> otherwise.</returns>
|
||||
private static bool IsConcurrencyConflict(SqliteException exception)
|
||||
{
|
||||
return exception.SqliteErrorCode is 5 or 6; // SQLITE_BUSY, SQLITE_LOCKED
|
||||
return exception.SqliteErrorCode is 5 or 6; // SQLITE_BUSY, SQLITE_LOCKED.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ internal sealed class ArtworkProviderConfigurationRepository : IArtworkProviderC
|
||||
_luminaDbContext.LibraryArtworkProviderConfigurations.Add(configuration);
|
||||
else
|
||||
{
|
||||
// update only the mutable fields, preserving the Id of the existing configuration
|
||||
// Update only the mutable fields, preserving the Id of the existing configuration.
|
||||
existingConfiguration.LibraryId = configuration.LibraryId;
|
||||
existingConfiguration.PluginId = configuration.PluginId;
|
||||
existingConfiguration.IsEnabled = configuration.IsEnabled;
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ internal sealed class LibraryMetadataProviderConfigurationRepository : ILibraryM
|
||||
_luminaDbContext.LibraryMetadataProviderConfigurations.Add(configuration);
|
||||
else
|
||||
{
|
||||
// update only the mutable fields, preserving the Id of the existing configuration
|
||||
// Update only the mutable fields, preserving the Id of the existing configuration.
|
||||
existingConfiguration.LibraryId = configuration.LibraryId;
|
||||
existingConfiguration.PluginId = configuration.PluginId;
|
||||
existingConfiguration.IsEnabled = configuration.IsEnabled;
|
||||
|
||||
@@ -503,7 +503,7 @@ public class UnitOfWork : IUnitOfWork, IDisposable
|
||||
{
|
||||
// SQLite reports a generic constraint failure code for several constraints, so the extended code is used to tell a unique violation apart.
|
||||
return exception.InnerException is SqliteException sqliteException
|
||||
&& sqliteException.SqliteExtendedErrorCode == 2067; // SQLITE_CONSTRAINT_UNIQUE
|
||||
&& sqliteException.SqliteExtendedErrorCode == 2067; // SQLITE_CONSTRAINT_UNIQUE.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -523,7 +523,7 @@ public class UnitOfWork : IUnitOfWork, IDisposable
|
||||
/// <returns><see langword="true"/> if the database is busy or locked, <see langword="false"/> otherwise.</returns>
|
||||
private static bool IsSqliteBusyOrLocked(SqliteException exception)
|
||||
{
|
||||
return exception.SqliteErrorCode is 5 or 6; // SQLITE_BUSY, SQLITE_LOCKED
|
||||
return exception.SqliteErrorCode is 5 or 6; // SQLITE_BUSY, SQLITE_LOCKED.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user