mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-07 15:24:31 +01:00
Deleting legacy DBriize database if present
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Configuration;
|
||||
using BTCPayServer.Data;
|
||||
using BTCPayServer.Services;
|
||||
using BTCPayServer.Services.Invoices;
|
||||
@@ -16,12 +18,14 @@ namespace BTCPayServer.HostedServices
|
||||
private readonly InvoiceRepository _invoiceRepository;
|
||||
private readonly SettingsRepository _settingsRepository;
|
||||
private readonly ApplicationDbContextFactory _dbContextFactory;
|
||||
private readonly DataDirectories _datadirs;
|
||||
|
||||
public DbMigrationsHostedService(InvoiceRepository invoiceRepository, SettingsRepository settingsRepository, ApplicationDbContextFactory dbContextFactory)
|
||||
public DbMigrationsHostedService(InvoiceRepository invoiceRepository, SettingsRepository settingsRepository, ApplicationDbContextFactory dbContextFactory, DataDirectories datadirs)
|
||||
{
|
||||
_invoiceRepository = invoiceRepository;
|
||||
_settingsRepository = settingsRepository;
|
||||
_dbContextFactory = dbContextFactory;
|
||||
_datadirs = datadirs;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +47,14 @@ namespace BTCPayServer.HostedServices
|
||||
|
||||
private async Task MigratedInvoiceTextSearchToDb(int startFromPage)
|
||||
{
|
||||
// deleting legacy DBriize database if present
|
||||
var dbpath = Path.Combine(_datadirs.DataDir, "InvoiceDB");
|
||||
if (Directory.Exists(dbpath))
|
||||
{
|
||||
Directory.Delete(dbpath, true);
|
||||
}
|
||||
|
||||
// migrate data to new table using invoices from database
|
||||
using var ctx = _dbContextFactory.CreateContext();
|
||||
|
||||
var invoiceQuery = new InvoiceQuery { IncludeArchived = true };
|
||||
|
||||
Reference in New Issue
Block a user