aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/UserDataConfiguration.cs
blob: 47604d32173344e142591bb68b18573395a72db9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Jellyfin.Database.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.ItemId, d.UserId, d.CustomDataKey });
        builder.HasIndex(d => new { d.ItemId, d.UserId, d.Played });
        builder.HasIndex(d => new { d.ItemId, d.UserId, d.PlaybackPositionTicks });
        builder.HasIndex(d => new { d.ItemId, d.UserId, d.IsFavorite });
        builder.HasIndex(d => new { d.ItemId, d.UserId, d.LastPlayedDate });
        builder.HasOne(e => e.Item);
    }
}