mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Migrate PayoutProcessors's PayoutMethodId in entity migration
This commit is contained in:
parent
25e360e175
commit
b726ef8a2e
2 changed files with 9 additions and 17 deletions
|
@ -26,6 +26,15 @@ namespace BTCPayServer.Migrations
|
|||
name: "PaymentMethod",
|
||||
table: "PayoutProcessors",
|
||||
newName: "PayoutMethodId");
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE "PayoutProcessors"
|
||||
SET
|
||||
"PaymentMethodId" = CASE WHEN STRPOS("PaymentMethodId", '_') = 0 THEN "PaymentMethodId" || '-CHAIN'
|
||||
CASE WHEN STRPOS("PaymentMethodId", '_LightningLike') = 0 THEN "PaymentMethodId" || '-LN'
|
||||
CASE WHEN STRPOS("PaymentMethodId", '_LNURLPAY') = 0 THEN "PaymentMethodId" || '-LN'
|
||||
ELSE "PaymentMethodId" END;
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -211,12 +211,6 @@ namespace BTCPayServer.Hosting
|
|||
settings.MigrateToStoreConfig = true;
|
||||
await _Settings.UpdateSetting(settings);
|
||||
}
|
||||
if (!settings.MigratePayoutProcessors)
|
||||
{
|
||||
await MigratePayoutProcessors();
|
||||
settings.MigratePayoutProcessors = true;
|
||||
await _Settings.UpdateSetting(settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -225,17 +219,6 @@ namespace BTCPayServer.Hosting
|
|||
}
|
||||
}
|
||||
|
||||
private async Task MigratePayoutProcessors()
|
||||
{
|
||||
await using var ctx = _DBContextFactory.CreateContext();
|
||||
var processors = await ctx.PayoutProcessors.ToArrayAsync();
|
||||
foreach (var processor in processors)
|
||||
{
|
||||
processor.PayoutMethodId = processor.GetPayoutMethodId().ToString();
|
||||
}
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private async Task MigrateToStoreConfig()
|
||||
{
|
||||
await using var ctx = _DBContextFactory.CreateContext();
|
||||
|
|
Loading…
Add table
Reference in a new issue