2020-06-28 21:44:35 -05:00
|
|
|
using System;
|
2020-06-24 10:34:09 +09:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2021-10-21 17:43:02 +02:00
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2024-03-14 19:13:26 +09:00
|
|
|
using System.Text;
|
2021-04-13 10:36:49 +02:00
|
|
|
using BTCPayServer.Client.Models;
|
2020-06-24 10:34:09 +09:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-03-14 19:13:26 +09:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
2020-06-24 10:34:09 +09:00
|
|
|
using NBitcoin;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2024-06-28 20:07:53 +09:00
|
|
|
public partial class PayoutData
|
2020-06-24 10:34:09 +09:00
|
|
|
{
|
|
|
|
[Key]
|
|
|
|
[MaxLength(30)]
|
|
|
|
public string Id { get; set; }
|
|
|
|
public DateTimeOffset Date { get; set; }
|
|
|
|
public string PullPaymentDataId { get; set; }
|
2022-04-24 05:19:34 +02:00
|
|
|
public string StoreDataId { get; set; }
|
2024-06-28 20:07:53 +09:00
|
|
|
public string Currency { get; set; }
|
2020-06-24 10:34:09 +09:00
|
|
|
public PullPaymentData PullPaymentData { get; set; }
|
|
|
|
[MaxLength(20)]
|
|
|
|
public PayoutState State { get; set; }
|
|
|
|
[MaxLength(20)]
|
|
|
|
[Required]
|
2024-06-28 20:07:53 +09:00
|
|
|
public string PayoutMethodId { get; set; }
|
2024-03-14 19:13:26 +09:00
|
|
|
public string Blob { get; set; }
|
|
|
|
public string Proof { get; set; }
|
2021-10-23 22:10:54 +09:00
|
|
|
#nullable enable
|
2021-10-21 17:43:02 +02:00
|
|
|
public string? Destination { get; set; }
|
2021-10-23 22:10:54 +09:00
|
|
|
#nullable restore
|
2022-04-24 05:19:34 +02:00
|
|
|
public StoreData StoreData { get; set; }
|
2020-12-28 14:57:21 -06:00
|
|
|
|
2024-03-14 19:13:26 +09:00
|
|
|
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
2020-06-24 10:34:09 +09:00
|
|
|
{
|
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.HasOne(o => o.PullPaymentData)
|
|
|
|
.WithMany(o => o.Payouts).OnDelete(DeleteBehavior.Cascade);
|
2022-04-24 05:19:34 +02:00
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(o => o.Payouts).OnDelete(DeleteBehavior.Cascade);
|
2020-06-24 10:34:09 +09:00
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.Property(o => o.State)
|
|
|
|
.HasConversion<string>();
|
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.HasIndex(o => o.State);
|
2021-10-21 17:43:02 +02:00
|
|
|
builder.Entity<PayoutData>()
|
2021-12-31 16:59:02 +09:00
|
|
|
.HasIndex(x => new { DestinationId = x.Destination, x.State });
|
2024-03-14 19:13:26 +09:00
|
|
|
|
2024-04-15 19:08:25 +09:00
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.Property(o => o.Blob)
|
|
|
|
.HasColumnType("JSONB");
|
|
|
|
builder.Entity<PayoutData>()
|
|
|
|
.Property(o => o.Proof)
|
|
|
|
.HasColumnType("JSONB");
|
2020-06-24 10:34:09 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|