Merge pull request #293 from BinaryAlley/feature/filter-book-deleted-items-ordering-index

Filters the book deleted-items ordering index by IsDeleted
This commit is contained in:
BinaryAlley authored and GitHub committed 2026-11-17 08:50:36 +02:00
commit 00699de5bb
4 files changed
+3999 -2

No files matched your search

@@ -235,6 +235,8 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus }); 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 // 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. // index follows the same order and no temporary B-tree is needed for the sort.
builder.HasIndex(book => new { book.LibraryId, book.IsDeleted, book.DeletedOnUtc, book.Title, book.Id }); // Only deleted books maintain an entry in the index, since visible books never appear in the listing.
builder.HasIndex(book => new { book.LibraryId, book.IsDeleted, book.DeletedOnUtc, book.Title, book.Id })
.HasFilter("\"IsDeleted\" = 1");
} }
} }
@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class FiltersBookDeletedItemsOrderingIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
table: "Books");
migrationBuilder.CreateIndex(
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
table: "Books",
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id" },
filter: "\"IsDeleted\" = 1");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
table: "Books");
migrationBuilder.CreateIndex(
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
table: "Books",
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id" });
}
}
}
@@ -2117,7 +2117,8 @@ namespace Lumina.DataAccess.Common.Migrations
b.HasIndex("LibraryId", "Path") b.HasIndex("LibraryId", "Path")
.IsUnique(); .IsUnique();
b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id"); b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id")
.HasFilter("\"IsDeleted\" = 1");
b.ToTable("Books", (string)null); b.ToTable("Books", (string)null);
}); });