aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/JellyfinDb.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server.Implementations/JellyfinDb.cs')
-rw-r--r--Jellyfin.Server.Implementations/JellyfinDb.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/JellyfinDb.cs b/Jellyfin.Server.Implementations/JellyfinDb.cs
index db648472d..6f35a2c1c 100644
--- a/Jellyfin.Server.Implementations/JellyfinDb.cs
+++ b/Jellyfin.Server.Implementations/JellyfinDb.cs
@@ -4,6 +4,7 @@
using System;
using System.Linq;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Entities.Security;
using Jellyfin.Data.Interfaces;
using Microsoft.EntityFrameworkCore;
@@ -29,6 +30,12 @@ namespace Jellyfin.Server.Implementations
public virtual DbSet<ActivityLog> ActivityLogs { get; set; }
+ public virtual DbSet<ApiKey> ApiKeys { get; set; }
+
+ public virtual DbSet<Device> Devices { get; set; }
+
+ public virtual DbSet<DeviceOptions> DeviceOptions { get; set; }
+
public virtual DbSet<DisplayPreferences> DisplayPreferences { get; set; }
public virtual DbSet<ImageInfo> ImageInfos { get; set; }
@@ -196,10 +203,30 @@ namespace Jellyfin.Server.Implementations
// Indexes
+ modelBuilder.Entity<ApiKey>()
+ .HasIndex(entity => entity.AccessToken)
+ .IsUnique();
+
modelBuilder.Entity<User>()
.HasIndex(entity => entity.Username)
.IsUnique();
+ modelBuilder.Entity<Device>()
+ .HasIndex(entity => new { entity.DeviceId, entity.DateLastActivity });
+
+ modelBuilder.Entity<Device>()
+ .HasIndex(entity => new { entity.AccessToken, entity.DateLastActivity });
+
+ modelBuilder.Entity<Device>()
+ .HasIndex(entity => new { entity.UserId, entity.DeviceId });
+
+ modelBuilder.Entity<Device>()
+ .HasIndex(entity => entity.DeviceId);
+
+ modelBuilder.Entity<DeviceOptions>()
+ .HasIndex(entity => entity.DeviceId)
+ .IsUnique();
+
modelBuilder.Entity<DisplayPreferences>()
.HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client })
.IsUnique();