Fix potential migration crashes

This commit is contained in:
nicolas.dorier
2025-03-31 10:15:26 +09:00
parent 658ddd1f27
commit 78ddff3c9e
2 changed files with 3 additions and 1 deletions

View File

@@ -142,6 +142,7 @@ namespace BTCPayServer.Data
"LightningLike" or "LightningNetwork" => $"{cryptoCode}-LN",
"LNURLPAY" => $"{cryptoCode}-LNURL",
"EthereumLike" => $"{cryptoCode}-LEGACY",
"CHAIN" or "LNURL" or "LN" => paymentMethodId,
_ => throw new NotSupportedException("Unknown payment type " + paymentType)
};
}
@@ -159,6 +160,7 @@ namespace BTCPayServer.Data
"BTCLike" or "MoneroLike" or "ZcashLike" => $"{cryptoCode}-CHAIN",
"LightningLike" or "LightningNetwork" => $"{cryptoCode}-LN",
"LNURLPAY" => $"{cryptoCode}-LNURL",
"EthereumLike" => $"{cryptoCode}-LEGACY",
_ => paymentMethodId
};
}

View File

@@ -73,7 +73,7 @@ public class InvoiceBlobMigratorHostedService : BlobMigratorHostedService<Invoic
}
pay.SetBlob(paymentEntity);
if (pay.PaymentMethodId != pay.MigratedPaymentMethodId)
if (pay.MigratedPaymentMethodId is not null && pay.PaymentMethodId != pay.MigratedPaymentMethodId)
{
ctx.Add(pay);
ctx.Payments.Remove(new PaymentData() { Id = pay.Id, PaymentMethodId = pay.MigratedPaymentMethodId });