using System; using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; namespace BTCPayServer.Data { public class WebhookDeliveryData { [Key] [MaxLength(25)] public string Id { get; set; } [MaxLength(25)] [Required] public string WebhookId { get; set; } public WebhookData Webhook { get; set; } [Required] public DateTimeOffset Timestamp { get; set; } public string Blob { get; set; } public bool Pruned { get; set; } internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade) { builder.Entity() .HasOne(o => o.Webhook) .WithMany(a => a.Deliveries).OnDelete(DeleteBehavior.Cascade); builder.Entity().HasIndex(o => o.WebhookId); builder.Entity().HasIndex(o => o.Timestamp); if (databaseFacade.IsNpgsql()) { builder.Entity() .Property(o => o.Blob) .HasColumnType("JSONB"); } } } }