Refactors the track slice across the stack

This commit is contained in:
BinaryAlley committed 2026-09-25 13:19:28 -07:00
1 parent e842c7baaf
commit 6bd0cf6d42
37 files changed
+853 -403

No files matched your search

@@ -157,37 +157,6 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
j.ToTable("TrackGenres");
});
builder.OwnsMany(track => track.Ratings, ratingBuilder =>
{
ratingBuilder.ToTable("TrackRatings");
ratingBuilder.WithOwner()
.HasForeignKey("TrackId");
ratingBuilder.Property<Guid>("Id")
.ValueGeneratedOnAdd();
ratingBuilder.HasKey("Id");
ratingBuilder.Property(rating => rating.Value)
.HasColumnType("decimal(3,2)")
.IsRequired();
ratingBuilder.Property(rating => rating.MaxValue)
.HasColumnType("decimal(3,2)")
.IsRequired();
ratingBuilder.Property(rating => rating.VoteCount)
.IsRequired(false);
ratingBuilder.Property(rating => rating.Source)
.HasConversion<string>()
.HasMaxLength(50)
.IsRequired(false);
});
builder.HasMany(track => track.Contributors)
.WithOne()
.HasForeignKey(contributor => contributor.TrackId)
.OnDelete(DeleteBehavior.Cascade);
builder.OwnsMany(track => track.Moods, moodBuilder =>
{
moodBuilder.ToTable("TrackMoods");
@@ -217,6 +186,37 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
.IsRequired();
});
builder.HasMany(track => track.Contributors)
.WithOne()
.HasForeignKey(contributor => contributor.TrackId)
.OnDelete(DeleteBehavior.Cascade);
builder.OwnsMany(track => track.Ratings, ratingBuilder =>
{
ratingBuilder.ToTable("TrackRatings");
ratingBuilder.WithOwner()
.HasForeignKey("TrackId");
ratingBuilder.Property<Guid>("Id")
.ValueGeneratedOnAdd();
ratingBuilder.HasKey("Id");
ratingBuilder.Property(rating => rating.Value)
.HasColumnType("decimal(3,2)")
.IsRequired();
ratingBuilder.Property(rating => rating.MaxValue)
.HasColumnType("decimal(3,2)")
.IsRequired();
ratingBuilder.Property(rating => rating.VoteCount)
.IsRequired(false);
ratingBuilder.Property(rating => rating.Source)
.HasConversion<string>()
.HasMaxLength(50)
.IsRequired(false);
});
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