using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Threading.Tasks; using BTCPayServer.App.BackupStorage; using Laraue.EfCoreTriggers.PostgreSql.Extensions; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Infrastructure; namespace BTCPayServer.Data { public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory { public ApplicationDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder(); // 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"); builder.UsePostgreSqlTriggers(); return new ApplicationDbContext(builder.Options); } } public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { } public DbSet AddressInvoices { get; set; } public DbSet AppStorageItems { get; set; } public DbSet ApiKeys { get; set; } public DbSet Apps { get; set; } public DbSet Files { get; set; } public DbSet InvoiceSearches { get; set; } public DbSet InvoiceWebhookDeliveries { get; set; } public DbSet Invoices { get; set; } public DbSet Notifications { get; set; } public DbSet OffchainTransactions { get; set; } public DbSet PairedSINData { get; set; } public DbSet PairingCodes { get; set; } public DbSet PayjoinLocks { get; set; } public DbSet PaymentRequests { get; set; } public DbSet Payments { get; set; } public DbSet Payouts { get; set; } public DbSet PlannedTransactions { get; set; } public DbSet PullPayments { get; set; } public DbSet Refunds { get; set; } public DbSet Settings { get; set; } public DbSet StoreSettings { get; set; } public DbSet StoreWebhooks { get; set; } public DbSet Stores { get; set; } public DbSet U2FDevices { get; set; } public DbSet Fido2Credentials { get; set; } public DbSet UserStore { get; set; } public DbSet StoreRoles { get; set; } [Obsolete] public DbSet Wallets { get; set; } public DbSet WalletObjects { get; set; } public DbSet WalletObjectLinks { get; set; } [Obsolete] public DbSet WalletTransactions { get; set; } public DbSet WebhookDeliveries { get; set; } public DbSet Webhooks { get; set; } public DbSet LightningAddresses { get; set; } public DbSet PayoutProcessors { get; set; } public DbSet Forms { get; set; } public DbSet PendingTransactions { get; set; } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // some of the data models don't have OnModelCreating for now, commenting them AppStorageItemData.OnModelCreating(builder); ApplicationUser.OnModelCreating(builder, Database); AddressInvoiceData.OnModelCreating(builder); APIKeyData.OnModelCreating(builder, Database); AppData.OnModelCreating(builder, Database); //StoredFile.OnModelCreating(builder); InvoiceSearchData.OnModelCreating(builder); InvoiceWebhookDeliveryData.OnModelCreating(builder); InvoiceData.OnModelCreating(builder, Database); NotificationData.OnModelCreating(builder, Database); //OffchainTransactionData.OnModelCreating(builder); BTCPayServer.Data.PairedSINData.OnModelCreating(builder); PairingCodeData.OnModelCreating(builder); //PayjoinLock.OnModelCreating(builder); PaymentRequestData.OnModelCreating(builder, Database); PaymentData.OnModelCreating(builder); PayoutData.OnModelCreating(builder, Database); //PlannedTransaction.OnModelCreating(builder); PullPaymentData.OnModelCreating(builder, Database); RefundData.OnModelCreating(builder); SettingData.OnModelCreating(builder, Database); StoreSettingData.OnModelCreating(builder, Database); StoreWebhookData.OnModelCreating(builder); StoreData.OnModelCreating(builder, Database); U2FDevice.OnModelCreating(builder); Fido2Credential.OnModelCreating(builder, Database); BTCPayServer.Data.UserStore.OnModelCreating(builder); //WalletData.OnModelCreating(builder); WalletObjectData.OnModelCreating(builder, Database); WalletObjectLinkData.OnModelCreating(builder, Database); #pragma warning disable CS0612 // Type or member is obsolete WalletTransactionData.OnModelCreating(builder); #pragma warning restore CS0612 // Type or member is obsolete WebhookDeliveryData.OnModelCreating(builder, Database); LightningAddressData.OnModelCreating(builder, Database); PayoutProcessorData.OnModelCreating(builder, Database); WebhookData.OnModelCreating(builder, Database); FormData.OnModelCreating(builder, Database); StoreRole.OnModelCreating(builder, Database); PendingTransaction.OnModelCreating(builder, Database); } } }