2020-05-19 19:59:23 +02:00
|
|
|
using System;
|
2020-06-27 21:55:16 +09:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-02-21 15:06:34 +09:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
2019-08-30 00:24:42 +09:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2023-02-21 15:06:34 +09:00
|
|
|
public class PaymentRequestData : IHasBlobUntyped
|
2019-08-30 00:24:42 +09:00
|
|
|
{
|
|
|
|
public string Id { get; set; }
|
2020-12-28 14:57:21 -06:00
|
|
|
public DateTimeOffset Created { get; set; }
|
2019-08-30 00:24:42 +09:00
|
|
|
public string StoreDataId { get; set; }
|
2020-05-08 12:33:47 +02:00
|
|
|
public bool Archived { get; set; }
|
2019-08-30 00:24:42 +09:00
|
|
|
|
|
|
|
public StoreData StoreData { get; set; }
|
|
|
|
|
2020-05-19 19:59:23 +02:00
|
|
|
public Client.Models.PaymentRequestData.PaymentRequestStatus Status { get; set; }
|
2019-08-30 00:24:42 +09:00
|
|
|
|
2023-02-21 15:06:34 +09:00
|
|
|
[Obsolete("Use Blob2 instead")]
|
2019-08-30 00:24:42 +09:00
|
|
|
public byte[] Blob { get; set; }
|
2023-02-21 15:06:34 +09:00
|
|
|
public string Blob2 { get; set; }
|
2020-06-27 21:55:16 +09:00
|
|
|
|
2020-12-28 14:57:21 -06:00
|
|
|
|
2023-02-21 15:06:34 +09:00
|
|
|
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
2020-06-27 21:55:16 +09:00
|
|
|
{
|
|
|
|
builder.Entity<PaymentRequestData>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(i => i.PaymentRequests)
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.Entity<PaymentRequestData>()
|
|
|
|
.Property(e => e.Created)
|
|
|
|
.HasDefaultValue(new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero));
|
|
|
|
builder.Entity<PaymentRequestData>()
|
|
|
|
.HasIndex(o => o.Status);
|
2023-02-21 15:06:34 +09:00
|
|
|
|
|
|
|
if (databaseFacade.IsNpgsql())
|
|
|
|
{
|
|
|
|
builder.Entity<PaymentRequestData>()
|
|
|
|
.Property(o => o.Blob2)
|
|
|
|
.HasColumnType("JSONB");
|
|
|
|
}
|
2020-06-27 21:55:16 +09:00
|
|
|
}
|
2019-08-30 00:24:42 +09:00
|
|
|
}
|
|
|
|
}
|