// <copyright file="PeopleBaseItemMapConfiguration.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>
/// People configuration.
/// </summary>
public class PeopleBaseItemMapConfiguration : IEntityTypeConfiguration<PeopleBaseItemMap>
{
    /// <inheritdoc/>
    public void Configure(EntityTypeBuilder<PeopleBaseItemMap> builder)
    {
        ArgumentNullException.ThrowIfNull(builder);
        builder.HasKey(e => new { e.ItemId, e.PeopleId, e.Role });
        builder.HasIndex(e => new { e.ItemId, e.SortOrder });
        builder.HasIndex(e => new { e.ItemId, e.ListOrder });
        builder.HasOne(e => e.Item);
        builder.HasOne(e => e.People);
    }
}
