mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Adds provider configuration to media library saves
Moves metadata provider, artwork provider, and book reader choices into the add and update library requests, adds the library type lookups, removes the per-provider enable and reorder endpoints, and reconciles the stored configurations in one provider store call. Tightens library update and delete authorization to require ownership and the manage permission, and cleans up enum validation, comments, resource diacritics, and Razor imports.
This commit is contained in:
1 parent
2e7563199a
commit
48ad8692af
148 files changed
+6305
-2936
No files matched your search
+6
-3
@@ -20,7 +20,7 @@ public class LibraryArtworkProviderConfigurationConfiguration : IEntityTypeConfi
|
||||
builder.ToTable("LibraryArtworkProviderConfigurations");
|
||||
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()
|
||||
@@ -35,7 +35,7 @@ public class LibraryArtworkProviderConfigurationConfiguration : IEntityTypeConfi
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(configuration => configuration.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
@@ -52,6 +52,9 @@ public class LibraryArtworkProviderConfigurationConfiguration : IEntityTypeConfi
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId });
|
||||
// A media library has at most one artwork provider configuration per plugin, so the pair is unique; the repository upserts on it, and
|
||||
// the constraint guarantees that two concurrent upserts cannot insert duplicate rows.
|
||||
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -20,7 +20,7 @@ public class LibraryMetadataProviderConfigurationConfiguration : IEntityTypeConf
|
||||
builder.ToTable("LibraryMetadataProviderConfigurations");
|
||||
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()
|
||||
@@ -35,7 +35,7 @@ public class LibraryMetadataProviderConfigurationConfiguration : IEntityTypeConf
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// audit
|
||||
// Audit.
|
||||
builder.Property(configuration => configuration.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
@@ -52,6 +52,9 @@ public class LibraryMetadataProviderConfigurationConfiguration : IEntityTypeConf
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId });
|
||||
// A media library has at most one metadata provider configuration per plugin, so the pair is unique; the repository upserts on it, and
|
||||
// the constraint guarantees that two concurrent upserts cannot insert duplicate rows.
|
||||
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
+3904
File diff suppressed because it is too large.
Load diff
+72
@@ -0,0 +1,72 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MakesProviderConfigurationsUniquePerLibraryAndPlugin : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// The upserts read before they add, so two concurrent ones could store the same plugin twice for a library; the duplicates are removed before the
|
||||
// indexes become unique, keeping the configuration that is tried first, so the unique indexes can be created on an existing database.
|
||||
migrationBuilder.Sql("""
|
||||
DELETE FROM LibraryMetadataProviderConfigurations WHERE rowid NOT IN (
|
||||
SELECT rowid FROM (
|
||||
SELECT rowid, ROW_NUMBER() OVER (PARTITION BY LibraryId, PluginId ORDER BY Rank, rowid) AS RowNumber
|
||||
FROM LibraryMetadataProviderConfigurations)
|
||||
WHERE RowNumber = 1);
|
||||
|
||||
DELETE FROM LibraryArtworkProviderConfigurations WHERE rowid NOT IN (
|
||||
SELECT rowid FROM (
|
||||
SELECT rowid, ROW_NUMBER() OVER (PARTITION BY LibraryId, PluginId ORDER BY Rank, rowid) AS RowNumber
|
||||
FROM LibraryArtworkProviderConfigurations)
|
||||
WHERE RowNumber = 1);
|
||||
""");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_LibraryMetadataProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryMetadataProviderConfigurations");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_LibraryArtworkProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryArtworkProviderConfigurations");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LibraryMetadataProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryMetadataProviderConfigurations",
|
||||
columns: new[] { "LibraryId", "PluginId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LibraryArtworkProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryArtworkProviderConfigurations",
|
||||
columns: new[] { "LibraryId", "PluginId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_LibraryMetadataProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryMetadataProviderConfigurations");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_LibraryArtworkProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryArtworkProviderConfigurations");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LibraryMetadataProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryMetadataProviderConfigurations",
|
||||
columns: new[] { "LibraryId", "PluginId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LibraryArtworkProviderConfigurations_LibraryId_PluginId",
|
||||
table: "LibraryArtworkProviderConfigurations",
|
||||
columns: new[] { "LibraryId", "PluginId" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2223,7 +2223,8 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LibraryId", "PluginId");
|
||||
b.HasIndex("LibraryId", "PluginId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("LibraryArtworkProviderConfigurations", (string)null);
|
||||
});
|
||||
@@ -2310,7 +2311,8 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LibraryId", "PluginId");
|
||||
b.HasIndex("LibraryId", "PluginId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("LibraryMetadataProviderConfigurations", (string)null);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user