mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-04 07:46:32 +01:00
Add ImageInfo index
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Jellyfin.Database.Implementations.ModelConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// FluentAPI configuration for the BaseItemImageInfo entity.
|
||||
/// </summary>
|
||||
public class BaseItemImageInfoConfiguration : IEntityTypeConfiguration<BaseItemImageInfo>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void Configure(EntityTypeBuilder<BaseItemImageInfo> builder)
|
||||
{
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.HasOne(e => e.Item).WithMany(e => e.Images).HasForeignKey(e => e.ItemId);
|
||||
|
||||
// Index for efficient lookups and deletes by ItemId
|
||||
builder.HasIndex(e => e.ItemId);
|
||||
|
||||
// Composite index for filtering by item and image type
|
||||
builder.HasIndex(e => new { e.ItemId, e.ImageType });
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Jellyfin.Database.Providers.Sqlite.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddIndicesToImageInfo : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BaseItemImageInfos_ItemId_ImageType",
|
||||
table: "BaseItemImageInfos",
|
||||
columns: new[] { "ItemId", "ImageType" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_BaseItemImageInfos_ItemId_ImageType",
|
||||
table: "BaseItemImageInfos");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,6 +450,8 @@ namespace Jellyfin.Server.Implementations.Migrations
|
||||
|
||||
b.HasIndex("ItemId");
|
||||
|
||||
b.HasIndex("ItemId", "ImageType");
|
||||
|
||||
b.ToTable("BaseItemImageInfos");
|
||||
|
||||
b.HasAnnotation("Sqlite:UseSqlReturningClause", false);
|
||||
|
||||
Reference in New Issue
Block a user