using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using e_suite.Database.Audit.Attributes;
using e_suite.Database.Audit.Models;
using Microsoft.EntityFrameworkCore;

namespace e_suite.Database.Core.Tables.Miscellaneous;

[NoAudit]
[Table("ExternalKeys", Schema = "Miscellaneous")]
[Index(nameof(EntityName), nameof(PrimaryKey), IsUnique = true)]
[Index(nameof(ExternalSystemId), nameof(ExternalId), IsUnique = true)]
public class ExternalKey : IId
{
    [Key]
    public long Id { get; set; }

    [Required]
    public string EntityName { get; set; } = null!;

    [Required]
    public string PrimaryKey { get; set; } = string.Empty;

    [Required]
    public long ExternalSystemId { get; set; }

    [ForeignKey(nameof(ExternalSystemId))]
    public virtual ExternalSystem ExternalSystem { get; set; } = null!;

    [Required]
    public string ExternalId { get; set; } = string.Empty;
}