2020-06-29 04:44:35 +02:00
|
|
|
using System;
|
2024-12-10 13:56:52 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2019-08-29 17:24:42 +02:00
|
|
|
using System.Linq;
|
2023-02-10 03:43:46 +01:00
|
|
|
using System.Threading.Tasks;
|
2024-07-25 14:51:15 +02:00
|
|
|
using BTCPayServer.App.BackupStorage;
|
|
|
|
using Laraue.EfCoreTriggers.PostgreSql.Extensions;
|
2017-09-13 08:47:34 +02:00
|
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2020-01-19 13:57:50 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Design;
|
2017-09-27 15:09:59 +02:00
|
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2020-01-19 13:57:50 +01:00
|
|
|
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
2020-01-19 13:57:50 +01:00
|
|
|
public ApplicationDbContext CreateDbContext(string[] args)
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
2020-01-19 13:57:50 +01:00
|
|
|
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
2024-04-15 12:08:25 +02:00
|
|
|
// Same as launchsettings.json, it's connecting to the docker's postgres.
|
|
|
|
builder.UseNpgsql("User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=btcpayserver");
|
2024-07-25 14:51:15 +02:00
|
|
|
builder.UsePostgreSqlTriggers();
|
2024-04-15 12:08:25 +02:00
|
|
|
return new ApplicationDbContext(builder.Options);
|
2017-10-27 10:53:04 +02:00
|
|
|
}
|
2020-01-19 13:57:50 +01:00
|
|
|
}
|
|
|
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
|
|
|
{
|
2024-04-15 12:08:25 +02:00
|
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
2017-10-27 10:53:04 +02:00
|
|
|
: base(options)
|
|
|
|
{
|
2023-02-10 03:43:46 +01:00
|
|
|
}
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<AddressInvoiceData> AddressInvoices { get; set; }
|
2024-07-25 14:51:15 +02:00
|
|
|
public DbSet<AppStorageItemData> AppStorageItems { get; set; }
|
|
|
|
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<APIKeyData> ApiKeys { get; set; }
|
2020-05-28 21:38:17 +02:00
|
|
|
public DbSet<AppData> Apps { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<StoredFile> Files { get; set; }
|
2020-12-28 23:38:02 +01:00
|
|
|
public DbSet<InvoiceSearchData> InvoiceSearches { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<InvoiceWebhookDeliveryData> InvoiceWebhookDeliveries { get; set; }
|
|
|
|
public DbSet<InvoiceData> Invoices { get; set; }
|
|
|
|
public DbSet<NotificationData> Notifications { get; set; }
|
2020-04-16 07:25:52 +02:00
|
|
|
public DbSet<OffchainTransactionData> OffchainTransactions { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<PairedSINData> PairedSINData { get; set; }
|
|
|
|
public DbSet<PairingCodeData> PairingCodes { get; set; }
|
|
|
|
public DbSet<PayjoinLock> PayjoinLocks { get; set; }
|
2020-05-28 21:38:17 +02:00
|
|
|
public DbSet<PaymentRequestData> PaymentRequests { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<PaymentData> Payments { get; set; }
|
2020-06-24 03:34:09 +02:00
|
|
|
public DbSet<PayoutData> Payouts { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<PlannedTransaction> PlannedTransactions { get; set; }
|
|
|
|
public DbSet<PullPaymentData> PullPayments { get; set; }
|
|
|
|
public DbSet<RefundData> Refunds { get; set; }
|
2020-05-28 21:38:17 +02:00
|
|
|
public DbSet<SettingData> Settings { get; set; }
|
2022-06-13 06:36:47 +02:00
|
|
|
public DbSet<StoreSettingData> StoreSettings { get; set; }
|
2020-11-06 12:42:26 +01:00
|
|
|
public DbSet<StoreWebhookData> StoreWebhooks { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<StoreData> Stores { get; set; }
|
|
|
|
public DbSet<U2FDevice> U2FDevices { get; set; }
|
2021-04-20 07:06:32 +02:00
|
|
|
public DbSet<Fido2Credential> Fido2Credentials { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<UserStore> UserStore { get; set; }
|
2023-05-26 16:49:32 +02:00
|
|
|
public DbSet<StoreRole> StoreRoles { get; set; }
|
2022-10-11 10:34:29 +02:00
|
|
|
[Obsolete]
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<WalletData> Wallets { get; set; }
|
2022-10-11 10:34:29 +02:00
|
|
|
public DbSet<WalletObjectData> WalletObjects { get; set; }
|
|
|
|
public DbSet<WalletObjectLinkData> WalletObjectLinks { get; set; }
|
|
|
|
[Obsolete]
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<WalletTransactionData> WalletTransactions { get; set; }
|
2020-11-06 12:42:26 +01:00
|
|
|
public DbSet<WebhookDeliveryData> WebhookDeliveries { get; set; }
|
2020-12-28 23:32:15 +01:00
|
|
|
public DbSet<WebhookData> Webhooks { get; set; }
|
2023-01-06 14:18:07 +01:00
|
|
|
public DbSet<LightningAddressData> LightningAddresses { get; set; }
|
2022-04-24 05:19:34 +02:00
|
|
|
public DbSet<PayoutProcessorData> PayoutProcessors { get; set; }
|
2023-02-20 11:35:54 +01:00
|
|
|
public DbSet<FormData> Forms { get; set; }
|
2024-12-10 13:56:52 +01:00
|
|
|
public DbSet<PendingTransaction> PendingTransactions { get; set; }
|
2020-11-06 12:42:26 +01:00
|
|
|
|
2017-10-27 10:53:04 +02:00
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
|
|
{
|
|
|
|
base.OnModelCreating(builder);
|
2020-12-28 23:32:15 +01:00
|
|
|
|
|
|
|
// some of the data models don't have OnModelCreating for now, commenting them
|
2024-07-25 14:51:15 +02:00
|
|
|
AppStorageItemData.OnModelCreating(builder);
|
2023-02-21 07:06:34 +01:00
|
|
|
ApplicationUser.OnModelCreating(builder, Database);
|
2020-12-28 23:32:15 +01:00
|
|
|
AddressInvoiceData.OnModelCreating(builder);
|
2023-02-21 07:06:34 +01:00
|
|
|
APIKeyData.OnModelCreating(builder, Database);
|
2023-12-19 12:53:11 +01:00
|
|
|
AppData.OnModelCreating(builder, Database);
|
2020-12-28 23:32:15 +01:00
|
|
|
//StoredFile.OnModelCreating(builder);
|
|
|
|
InvoiceSearchData.OnModelCreating(builder);
|
|
|
|
InvoiceWebhookDeliveryData.OnModelCreating(builder);
|
2023-02-21 07:06:34 +01:00
|
|
|
InvoiceData.OnModelCreating(builder, Database);
|
|
|
|
NotificationData.OnModelCreating(builder, Database);
|
2020-12-28 23:32:15 +01:00
|
|
|
//OffchainTransactionData.OnModelCreating(builder);
|
2022-04-24 05:19:34 +02:00
|
|
|
BTCPayServer.Data.PairedSINData.OnModelCreating(builder);
|
2020-12-28 23:32:15 +01:00
|
|
|
PairingCodeData.OnModelCreating(builder);
|
|
|
|
//PayjoinLock.OnModelCreating(builder);
|
2023-02-21 07:06:34 +01:00
|
|
|
PaymentRequestData.OnModelCreating(builder, Database);
|
2024-09-23 10:06:56 +02:00
|
|
|
PaymentData.OnModelCreating(builder);
|
2024-03-14 11:13:26 +01:00
|
|
|
PayoutData.OnModelCreating(builder, Database);
|
2020-12-28 23:32:15 +01:00
|
|
|
//PlannedTransaction.OnModelCreating(builder);
|
2024-03-14 11:13:26 +01:00
|
|
|
PullPaymentData.OnModelCreating(builder, Database);
|
2020-06-24 10:51:00 +02:00
|
|
|
RefundData.OnModelCreating(builder);
|
2022-11-28 12:36:18 +01:00
|
|
|
SettingData.OnModelCreating(builder, Database);
|
2022-06-13 06:36:47 +02:00
|
|
|
StoreSettingData.OnModelCreating(builder, Database);
|
2020-12-28 23:32:15 +01:00
|
|
|
StoreWebhookData.OnModelCreating(builder);
|
2022-11-28 12:36:18 +01:00
|
|
|
StoreData.OnModelCreating(builder, Database);
|
2020-10-06 17:56:55 +02:00
|
|
|
U2FDevice.OnModelCreating(builder);
|
2023-02-21 07:06:34 +01:00
|
|
|
Fido2Credential.OnModelCreating(builder, Database);
|
2022-04-24 05:19:34 +02:00
|
|
|
BTCPayServer.Data.UserStore.OnModelCreating(builder);
|
2020-12-28 23:32:15 +01:00
|
|
|
//WalletData.OnModelCreating(builder);
|
2022-10-11 10:34:29 +02:00
|
|
|
WalletObjectData.OnModelCreating(builder, Database);
|
|
|
|
WalletObjectLinkData.OnModelCreating(builder, Database);
|
|
|
|
#pragma warning disable CS0612 // Type or member is obsolete
|
2020-12-28 23:32:15 +01:00
|
|
|
WalletTransactionData.OnModelCreating(builder);
|
2022-10-11 10:34:29 +02:00
|
|
|
#pragma warning restore CS0612 // Type or member is obsolete
|
2023-04-10 04:07:03 +02:00
|
|
|
WebhookDeliveryData.OnModelCreating(builder, Database);
|
|
|
|
LightningAddressData.OnModelCreating(builder, Database);
|
|
|
|
PayoutProcessorData.OnModelCreating(builder, Database);
|
|
|
|
WebhookData.OnModelCreating(builder, Database);
|
|
|
|
FormData.OnModelCreating(builder, Database);
|
2023-05-26 16:49:32 +02:00
|
|
|
StoreRole.OnModelCreating(builder, Database);
|
2024-12-10 13:56:52 +01:00
|
|
|
PendingTransaction.OnModelCreating(builder, Database);
|
2017-10-27 10:53:04 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|