// <copyright file="BaseItemAudioExtrasConfiguration.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>
/// EF Core configuration for <see cref="BaseItemAudioExtras"/>.
/// </summary>
public class BaseItemAudioExtrasConfiguration : IEntityTypeConfiguration<BaseItemAudioExtras>
{
    /// <inheritdoc/>
    public void Configure(EntityTypeBuilder<BaseItemAudioExtras> builder)
    {
        ArgumentNullException.ThrowIfNull(builder);

        builder.HasKey(e => e.ItemId);
        builder.ToTable("base_item_audio_extras", "library");

        builder.HasOne(e => e.Item)
            .WithOne(e => e.AudioExtras)
            .HasForeignKey<BaseItemAudioExtras>(e => e.ItemId)
            .OnDelete(DeleteBehavior.Cascade);
    }
}
