diff --git a/BTCPayServer.Data/Data/InvoiceData.cs b/BTCPayServer.Data/Data/InvoiceData.cs index 4bfc065f7..04a53348f 100644 --- a/BTCPayServer.Data/Data/InvoiceData.cs +++ b/BTCPayServer.Data/Data/InvoiceData.cs @@ -85,6 +85,7 @@ namespace BTCPayServer.Data .HasOne(o => o.StoreData) .WithMany(a => a.Invoices).OnDelete(DeleteBehavior.Cascade); builder.Entity().HasIndex(o => o.StoreDataId); + builder.Entity().HasIndex(o => o.OrderId); builder.Entity() .HasOne(o => o.CurrentRefund); } diff --git a/BTCPayServer.Data/Migrations/20201208054211_invoicesorderindex.cs b/BTCPayServer.Data/Migrations/20201208054211_invoicesorderindex.cs new file mode 100644 index 000000000..3bc12a32f --- /dev/null +++ b/BTCPayServer.Data/Migrations/20201208054211_invoicesorderindex.cs @@ -0,0 +1,26 @@ +using BTCPayServer.Data; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BTCPayServer.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20201208054211_invoicesorderindex")] + public partial class invoicesorderindex : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Invoices_OrderId", + table: "Invoices", + column: "OrderId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Invoices_OrderId", + table: "Invoices"); + } + } +} diff --git a/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs index ff64ecef3..8041007cf 100644 --- a/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/BTCPayServer.Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -228,6 +228,8 @@ namespace BTCPayServer.Migrations b.HasKey("Id"); + b.HasIndex("OrderId"); + b.HasIndex("StoreDataId"); b.HasIndex("Id", "CurrentRefundId");