// <copyright file="PreferenceConfiguration.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

namespace Jellyfin.Database.Implementations.ModelConfiguration
{
    using System;
    using Jellyfin.Database.Implementations.Entities;
    using Microsoft.EntityFrameworkCore;
    using Microsoft.EntityFrameworkCore.Metadata.Builders;

    /// <summary>
    /// FluentAPI configuration for the Permission entity.
    /// </summary>
    public class PreferenceConfiguration : IEntityTypeConfiguration<Preference>
    {
        /// <inheritdoc/>
        public void Configure(EntityTypeBuilder<Preference> builder)
        {
            ArgumentNullException.ThrowIfNull(builder);
            builder
                .HasIndex(p => new { p.UserId, p.Kind })
                .HasFilter("[UserId] IS NOT NULL")
                .IsUnique();
        }
    }
}
