Adds dynamic path templates for media libraries, so that the scanner can derive the meaning of each path part

This commit is contained in:
BinaryAlley committed 2026-10-05 18:42:00 +03:00
1 parent 62b0e9297a
commit ca4f308b0a
86 files changed
+7406 -151

No files matched your search

@@ -66,6 +66,11 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
.HasDefaultValue(null)
.HasColumnOrder(10);
builder.Property(library => library.PathTemplateFingerprint)
.HasMaxLength(64)
.HasDefaultValue(null)
.HasColumnOrder(11);
// one user with many libraries
builder.HasOne(library => library.User)
.WithMany(user => user.Libraries)
@@ -95,21 +100,48 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
.IsRequired();
});
// the path template parts are ordered, so their position is stored explicitly and part of a unique index together with the library
builder.OwnsMany(library => library.PathTemplateParts, partBuilder =>
{
partBuilder.ToTable("LibraryPathTemplateParts");
partBuilder.WithOwner()
.HasForeignKey("LibraryId");
partBuilder.Property<Guid>("Id")
.ValueGeneratedOnAdd();
partBuilder.HasKey("Id");
partBuilder.HasIndex("LibraryId", nameof(LibraryPathTemplatePartEntity.Position))
.IsUnique();
partBuilder.Property(part => part.Position)
.HasColumnName("Position")
.IsRequired();
partBuilder.Property(part => part.Kind)
.HasConversion<string>()
.HasMaxLength(32)
.IsRequired();
partBuilder.Property(part => part.Representation)
.HasMaxLength(512)
.IsRequired();
partBuilder.Property(part => part.IsOptional)
.IsRequired();
});
// audit
builder.Property(library => library.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(11);
.HasColumnOrder(12);
builder.Property(library => library.CreatedBy)
.IsRequired()
.HasColumnOrder(12);
.HasColumnOrder(13);
builder.Property(library => library.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(13);
.HasColumnOrder(14);
builder.Property(library => library.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(14);
.HasColumnOrder(15);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,146 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class AddsLibraryPathTemplate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "UpdatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 14)
.OldAnnotation("Relational:ColumnOrder", 13);
migrationBuilder.AlterColumn<Guid>(
name: "UpdatedBy",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 15)
.OldAnnotation("Relational:ColumnOrder", 14);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 12)
.OldAnnotation("Relational:ColumnOrder", 11);
migrationBuilder.AlterColumn<Guid>(
name: "CreatedBy",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(Guid),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 13)
.OldAnnotation("Relational:ColumnOrder", 12);
migrationBuilder.AddColumn<string>(
name: "PathTemplateFingerprint",
table: "Libraries",
type: "TEXT",
maxLength: 64,
nullable: true)
.Annotation("Relational:ColumnOrder", 11);
migrationBuilder.CreateTable(
name: "LibraryPathTemplateParts",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Position = table.Column<int>(type: "INTEGER", nullable: false),
Kind = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Representation = table.Column<string>(type: "TEXT", maxLength: 512, nullable: false),
IsOptional = table.Column<bool>(type: "INTEGER", nullable: false),
LibraryId = table.Column<Guid>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LibraryPathTemplateParts", x => x.Id);
table.ForeignKey(
name: "FK_LibraryPathTemplateParts_Libraries_LibraryId",
column: x => x.LibraryId,
principalTable: "Libraries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_LibraryPathTemplateParts_LibraryId_Position",
table: "LibraryPathTemplateParts",
columns: new[] { "LibraryId", "Position" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LibraryPathTemplateParts");
migrationBuilder.DropColumn(
name: "PathTemplateFingerprint",
table: "Libraries");
migrationBuilder.AlterColumn<DateTime>(
name: "UpdatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 13)
.OldAnnotation("Relational:ColumnOrder", 14);
migrationBuilder.AlterColumn<Guid>(
name: "UpdatedBy",
table: "Libraries",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true)
.Annotation("Relational:ColumnOrder", 14)
.OldAnnotation("Relational:ColumnOrder", 15);
migrationBuilder.AlterColumn<DateTime>(
name: "CreatedOnUtc",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 11)
.OldAnnotation("Relational:ColumnOrder", 12);
migrationBuilder.AlterColumn<Guid>(
name: "CreatedBy",
table: "Libraries",
type: "TEXT",
nullable: false,
oldClrType: typeof(Guid),
oldType: "TEXT")
.Annotation("Relational:ColumnOrder", 12)
.OldAnnotation("Relational:ColumnOrder", 13);
}
}
}
File diff suppressed because it is too large. Load diff