mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds book deletion and restore to the web client.
Soft deletes books so the scan keeps their paths reserved, lists the deleted books on a themed page, and lets the user restore them. Updates the API, bundled themes, localization, documentation and tests. Closes #213
This commit is contained in:
1 parent
ef5ede6325
commit
f26b07d4ff
125 files changed
+9856
-378
No files matched your search
@@ -149,6 +149,13 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
builder.Property(book => book.MetadataProvider)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(40);
|
||||
builder.Property(book => book.IsDeleted)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(41);
|
||||
builder.Property(book => book.DeletedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(42);
|
||||
|
||||
builder.HasMany(book => book.Contributors)
|
||||
.WithOne()
|
||||
@@ -226,5 +233,8 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
|
||||
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 });
|
||||
// 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.
|
||||
builder.HasIndex(book => new { book.LibraryId, book.IsDeleted, book.DeletedOnUtc, book.Title, book.Id });
|
||||
}
|
||||
}
|
||||
+3916
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddsBookDeletionState : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Books",
|
||||
type: "TEXT",
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 42);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDeleted",
|
||||
table: "Books",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false)
|
||||
.Annotation("Relational:ColumnOrder", 41);
|
||||
|
||||
// This migration introduces both deletion columns together, so a database coming from an older schema has no deleted books to backfill.
|
||||
// The statement is kept for databases that were created by an intermediate build that already had IsDeleted.
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE Books
|
||||
SET DeletedOnUtc = COALESCE(UpdatedOnUtc, CreatedOnUtc)
|
||||
WHERE IsDeleted = 1 AND DeletedOnUtc IS NULL;
|
||||
""");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Books",
|
||||
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Books_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Books");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Books");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDeleted",
|
||||
table: "Books");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1913,6 +1913,10 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(32);
|
||||
|
||||
b.Property<DateTime?>("DeletedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(42);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -1936,6 +1940,12 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(27);
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(41);
|
||||
|
||||
b.Property<string>("LCCN")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(23);
|
||||
@@ -2067,6 +2077,8 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b.HasIndex("LibraryId", "Path")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id");
|
||||
|
||||
b.ToTable("Books", (string)null);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user