aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/ModelConfiguration
diff options
context:
space:
mode:
authorJPVenson <6794763+JPVenson@users.noreply.github.com>2024-10-09 11:22:52 +0000
committerJPVenson <6794763+JPVenson@users.noreply.github.com>2024-10-09 11:22:52 +0000
commitc2844bda3b7605257d7b2f8d146077cea6dd0b08 (patch)
tree75f31171179ea555c13bc47973e0289ee5685abd /Jellyfin.Server.Implementations/ModelConfiguration
parent3dc402433870ba3dcd0f0c9f282ea96538e43c8b (diff)
Added EF BaseItem migration
Diffstat (limited to 'Jellyfin.Server.Implementations/ModelConfiguration')
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/AttachmentStreamInfoConfiguration.cs17
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs9
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs4
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs3
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/MediaStreamInfoConfiguration.cs22
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs2
-rw-r--r--Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs3
7 files changed, 49 insertions, 11 deletions
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
index 6f8adb44d..d74b94784 100644
--- a/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/BaseItemConfiguration.cs
@@ -2,6 +2,7 @@ using System;
using Jellyfin.Data.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using SQLitePCL;
namespace Jellyfin.Server.Implementations.ModelConfiguration;
@@ -14,10 +15,10 @@ public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
public void Configure(EntityTypeBuilder<BaseItemEntity> builder)
{
builder.HasKey(e => e.Id);
- builder.HasOne(e => e.Parent);
- builder.HasOne(e => e.TopParent);
- builder.HasOne(e => e.Season);
- builder.HasOne(e => e.Series);
+ 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);
diff --git a/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs b/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs
index 464fbfb01..5a84f7750 100644
--- a/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/ChapterConfiguration.cs
@@ -13,7 +13,7 @@ public class ChapterConfiguration : IEntityTypeConfiguration<Chapter>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<Chapter> builder)
{
- builder.HasNoKey();
- builder.HasIndex(e => new { e.ItemId, e.ChapterIndex });
+ 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
index a7de6ec32..c39854f5a 100644
--- a/Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/ItemValuesConfiguration.cs
@@ -13,8 +13,7 @@ public class ItemValuesConfiguration : IEntityTypeConfiguration<ItemValue>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<ItemValue> builder)
{
- builder.HasNoKey();
+ builder.HasKey(e => new { e.ItemId, e.Type, e.Value });
builder.HasIndex(e => new { e.ItemId, e.Type, e.CleanValue });
- builder.HasIndex(e => new { e.ItemId, e.Type, e.Value });
}
}
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
index f6cd39c24..5f5b4dfc7 100644
--- a/Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/PeopleConfiguration.cs
@@ -13,7 +13,7 @@ public class PeopleConfiguration : IEntityTypeConfiguration<People>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<People> builder)
{
- builder.HasNoKey();
+ 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
index 8e6484437..1113adb7b 100644
--- a/Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs
+++ b/Jellyfin.Server.Implementations/ModelConfiguration/UserDataConfiguration.cs
@@ -13,8 +13,7 @@ public class UserDataConfiguration : IEntityTypeConfiguration<UserData>
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<UserData> builder)
{
- builder.HasNoKey();
- builder.HasIndex(d => new { d.Key, d.UserId }).IsUnique();
+ 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 });