aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/ModelConfiguration/DisplayPreferencesConfiguration.cs
blob: 807078803d2c8ec244601d5e2489ecfef5b2f053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Jellyfin.Data.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Jellyfin.Server.Implementations.ModelConfiguration
{
    /// <summary>
    /// FluentAPI configuration for the DisplayPreferencesConfiguration entity.
    /// </summary>
    public class DisplayPreferencesConfiguration : IEntityTypeConfiguration<DisplayPreferences>
    {
        /// <inheritdoc/>
        public void Configure(EntityTypeBuilder<DisplayPreferences> builder)
        {
            // Delete behaviour

            builder
                .HasMany(d => d.HomeSections)
                .WithOne()
                .OnDelete(DeleteBehavior.Cascade);

            // Indexes

            builder
                .HasIndex(entity => new { entity.UserId, entity.ItemId, entity.Client })
                .IsUnique();
        }
    }
}