mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Refactors the add book slice and shared media contributor model across the stack
This commit is contained in:
1 parent
3a2c80b615
commit
9a71a6d32b
61 files changed
+5223
-1384
No files matched your search
@@ -227,7 +227,8 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(35);
|
||||
|
||||
builder.HasIndex(book => new { book.LibraryId, book.Path });
|
||||
builder.HasIndex(book => new { book.LibraryId, book.Path })
|
||||
.IsUnique(); // the same physical book on disk cannot appear twice in the same library
|
||||
builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus });
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaContributors;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
@@ -22,40 +22,36 @@ public class BookContributorConfiguration : IEntityTypeConfiguration<BookContrib
|
||||
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
|
||||
.HasColumnOrder(0);
|
||||
|
||||
builder.Property(bookContributor => bookContributor.BookId)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
builder.Property(bookContributor => bookContributor.MediaContributorId)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
builder.Property(bookContributor => bookContributor.RoleName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(3);
|
||||
builder.Property(bookContributor => bookContributor.RoleCategory)
|
||||
.IsRequired()
|
||||
builder.Property(bookContributor => bookContributor.Role)
|
||||
.HasConversion<string>()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnOrder(4);
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
// audit
|
||||
builder.Property(bookContributor => bookContributor.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(bookContributor => bookContributor.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
.HasColumnOrder(5);
|
||||
|
||||
builder.Property(bookContributor => bookContributor.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(7);
|
||||
.HasColumnOrder(6);
|
||||
|
||||
builder.Property(bookContributor => bookContributor.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
.HasColumnOrder(7);
|
||||
|
||||
builder.HasIndex(bookContributor => new { bookContributor.BookId, bookContributor.MediaContributorId });
|
||||
builder.HasIndex(bookContributor => new { bookContributor.BookId, bookContributor.MediaContributorId, bookContributor.Role })
|
||||
.IsUnique();
|
||||
builder.HasIndex(bookContributor => bookContributor.MediaContributorId);
|
||||
}
|
||||
}
|
||||
Generated
+2607
File diff suppressed because it is too large.
Load diff
+37
@@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddsUniqueBookLibraryIdPathIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Books_LibraryId_Path",
|
||||
table: "Books");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Books_LibraryId_Path",
|
||||
table: "Books",
|
||||
columns: new[] { "LibraryId", "Path" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Books_LibraryId_Path",
|
||||
table: "Books");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Books_LibraryId_Path",
|
||||
table: "Books",
|
||||
columns: new[] { "LibraryId", "Path" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user