aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/ModelConfiguration
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server.Implementations/ModelConfiguration')
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/AncestorIdConfiguration.cs20
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/AttachmentStreamInfoConfiguration.cs17
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs56
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/BaseItemProviderConfiguration.cs20
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs19
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs19
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/MediaStreamInfoConfiguration.cs22
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs20
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs22
9 files changed, 215 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/AncestorIdConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/AncestorIdConfiguration.cs
new file mode 100644
index 000000000..b7fe909dd
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/AncestorIdConfiguration.cs
@@ -0,0 +1,20 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// AncestorId configuration.
+/// </summary>
+public class AncestorIdConfiguration : IEntityTypeConfiguration<AncestorId>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<AncestorId> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.Id });
+ builder.HasIndex(e => e.Id);
+ builder.HasIndex(e => new { e.ItemId, e.AncestorIdText });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/AttachmentStreamInfoConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/AttachmentStreamInfoConfiguration.cs
new file mode 100644
index 000000000..057b6689a
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/AttachmentStreamInfoConfiguration.cs
@@ -0,0 +1,17 @@
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// FluentAPI configuration for the AttachmentStreamInfo entity.
+/// </summary>
+public class AttachmentStreamInfoConfiguration : IEntityTypeConfiguration<AttachmentStreamInfo>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<AttachmentStreamInfo> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.Index });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs
new file mode 100644
index 000000000..6c36a1591
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs
@@ -0,0 +1,56 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using SQLitePCL;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// Configuration for BaseItem.
+/// </summary>
+public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<BaseItemEntity> builder)
+ {
+ builder.HasKey(e => e.Id);
+ // TODO: See rant in entity file.
+ // builder.HasOne(e => e.Parent).WithMany(e => e.DirectChildren).HasForeignKey(e => e.ParentId);
+ // builder.HasOne(e => e.TopParent).WithMany(e => e.AllChildren).HasForeignKey(e => e.TopParentId);
+ // builder.HasOne(e => e.Season).WithMany(e => e.SeasonEpisodes).HasForeignKey(e => e.SeasonId);
+ // builder.HasOne(e => e.Series).WithMany(e => e.SeriesEpisodes).HasForeignKey(e => e.SeriesId);
+ builder.HasMany(e => e.Peoples);
+ builder.HasMany(e => e.UserData);
+ builder.HasMany(e => e.ItemValues);
+ builder.HasMany(e => e.MediaStreams);
+ builder.HasMany(e => e.Chapters);
+ builder.HasMany(e => e.Provider);
+ builder.HasMany(e => e.AncestorIds);
+
+ builder.HasIndex(e => e.Path);
+ builder.HasIndex(e => e.ParentId);
+ builder.HasIndex(e => e.PresentationUniqueKey);
+ builder.HasIndex(e => new { e.Id, e.Type, e.IsFolder, e.IsVirtualItem });
+ builder.HasIndex(e => new { e.UserDataKey, e.Type });
+
+ // covering index
+ builder.HasIndex(e => new { e.TopParentId, e.Id });
+ // series
+ builder.HasIndex(e => new { e.Type, e.SeriesPresentationUniqueKey, e.PresentationUniqueKey, e.SortName });
+ // series counts
+ // seriesdateplayed sort order
+ builder.HasIndex(e => new { e.Type, e.SeriesPresentationUniqueKey, e.IsFolder, e.IsVirtualItem });
+ // live tv programs
+ builder.HasIndex(e => new { e.Type, e.TopParentId, e.StartDate });
+ // covering index for getitemvalues
+ builder.HasIndex(e => new { e.Type, e.TopParentId, e.Id });
+ // used by movie suggestions
+ builder.HasIndex(e => new { e.Type, e.TopParentId, e.PresentationUniqueKey });
+ // latest items
+ builder.HasIndex(e => new { e.Type, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey, e.DateCreated });
+ builder.HasIndex(e => new { e.IsFolder, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey, e.DateCreated });
+ // resume
+ builder.HasIndex(e => new { e.MediaType, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemProviderConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemProviderConfiguration.cs
new file mode 100644
index 000000000..d15049a1f
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemProviderConfiguration.cs
@@ -0,0 +1,20 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// BaseItemProvider configuration.
+/// </summary>
+public class BaseItemProviderConfiguration : IEntityTypeConfiguration<BaseItemProvider>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<BaseItemProvider> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.ProviderId });
+ builder.HasOne(e => e.Item);
+ builder.HasIndex(e => new { e.ProviderId, e.ProviderValue, e.ItemId });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs
new file mode 100644
index 000000000..5a84f7750
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs
@@ -0,0 +1,19 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// Chapter configuration.
+/// </summary>
+public class ChapterConfiguration : IEntityTypeConfiguration<Chapter>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<Chapter> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.ChapterIndex });
+ builder.HasOne(e => e.Item);
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs
new file mode 100644
index 000000000..c39854f5a
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs
@@ -0,0 +1,19 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// itemvalues Configuration.
+/// </summary>
+public class ItemValuesConfiguration : IEntityTypeConfiguration<ItemValue>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<ItemValue> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.Type, e.Value });
+ builder.HasIndex(e => new { e.ItemId, e.Type, e.CleanValue });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/MediaStreamInfoConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/MediaStreamInfoConfiguration.cs
new file mode 100644
index 000000000..7e572f9a3
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/MediaStreamInfoConfiguration.cs
@@ -0,0 +1,22 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// People configuration.
+/// </summary>
+public class MediaStreamInfoConfiguration : IEntityTypeConfiguration<MediaStreamInfo>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<MediaStreamInfo> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.StreamIndex });
+ builder.HasIndex(e => e.StreamIndex);
+ builder.HasIndex(e => e.StreamType);
+ builder.HasIndex(e => new { e.StreamIndex, e.StreamType });
+ builder.HasIndex(e => new { e.StreamIndex, e.StreamType, e.Language });
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs
new file mode 100644
index 000000000..5f5b4dfc7
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs
@@ -0,0 +1,20 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// People configuration.
+/// </summary>
+public class PeopleConfiguration : IEntityTypeConfiguration<People>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<People> builder)
+ {
+ builder.HasKey(e => new { e.ItemId, e.Role, e.ListOrder });
+ builder.HasIndex(e => new { e.ItemId, e.ListOrder });
+ builder.HasIndex(e => e.Name);
+ }
+}
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs
new file mode 100644
index 000000000..1113adb7b
--- /dev/null
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs
@@ -0,0 +1,22 @@
+using System;
+using Jellyfin.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Jellyfin.Server.Implementations.ModelConfiguration;
+
+/// <summary>
+/// FluentAPI configuration for the UserData entity.
+/// </summary>
+public class UserDataConfiguration : IEntityTypeConfiguration<UserData>
+{
+ /// <inheritdoc/>
+ public void Configure(EntityTypeBuilder<UserData> builder)
+ {
+ builder.HasKey(d => new { d.Key, d.UserId });
+ builder.HasIndex(d => new { d.Key, d.UserId, d.Played });
+ builder.HasIndex(d => new { d.Key, d.UserId, d.PlaybackPositionTicks });
+ builder.HasIndex(d => new { d.Key, d.UserId, d.IsFavorite });
+ builder.HasIndex(d => new { d.Key, d.UserId, d.LastPlayedDate });
+ }
+}