mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Migrate excludedPaymentMethods from stores
This commit is contained in:
parent
663f97265a
commit
ca4a7d8771
2 changed files with 25 additions and 0 deletions
|
@ -217,6 +217,12 @@ namespace BTCPayServer.Hosting
|
|||
settings.MigrateBlockExplorerLinks = true;
|
||||
await _Settings.UpdateSetting(settings);
|
||||
}
|
||||
if (!settings.MigrateStoreExcludedPaymentMethods)
|
||||
{
|
||||
await MigrateStoreExcludedPaymentMethods();
|
||||
settings.MigrateStoreExcludedPaymentMethods = true;
|
||||
await _Settings.UpdateSetting(settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -225,6 +231,24 @@ namespace BTCPayServer.Hosting
|
|||
}
|
||||
}
|
||||
|
||||
private async Task MigrateStoreExcludedPaymentMethods()
|
||||
{
|
||||
await using var ctx = _DBContextFactory.CreateContext();
|
||||
var stores = await ctx.Stores.ToArrayAsync();
|
||||
foreach (var store in stores)
|
||||
{
|
||||
var blob = JObject.Parse(store.StoreBlob);
|
||||
var array = blob["excludedPaymentMethods"] as JArray;
|
||||
if (array is null || array.Count == 0)
|
||||
continue;
|
||||
var newArray = new JArray(array.Select(a => MigrationExtensions.MigratePaymentMethodId(a.Value<string>()))
|
||||
.ToArray());
|
||||
if (array.ToString() == newArray.ToString())
|
||||
continue;
|
||||
blob["excludedPaymentMethods"] = newArray;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task MigrateBlockExplorerLinks()
|
||||
{
|
||||
await using var ctx = _DBContextFactory.CreateContext();
|
||||
|
|
|
@ -32,5 +32,6 @@ namespace BTCPayServer.Services
|
|||
public bool MigrateAppYmlToJson { get; set; }
|
||||
public bool MigrateToStoreConfig { get; set; }
|
||||
public bool MigrateBlockExplorerLinks { get; set; }
|
||||
public bool MigrateStoreExcludedPaymentMethods { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue