forked from btcpayserver/btcpayserver
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
103 changed files
with
594 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE OR REPLACE FUNCTION get_orderid(invoice_blob jsonb) | ||
RETURNS text AS $$ | ||
SELECT invoice_blob->'metadata'->>'orderId'; | ||
$$ LANGUAGE sql IMMUTABLE; | ||
|
||
CREATE OR REPLACE FUNCTION get_itemcode(invoice_blob jsonb) | ||
RETURNS text AS $$ | ||
SELECT invoice_blob->'metadata'->>'itemCode'; | ||
$$ LANGUAGE sql IMMUTABLE; | ||
|
||
CREATE INDEX IF NOT EXISTS "IX_Invoices_Metadata_OrderId" ON "Invoices" (get_orderid("Blob2")) WHERE get_orderid("Blob2") IS NOT NULL; | ||
CREATE INDEX IF NOT EXISTS "IX_Invoices_Metadata_ItemCode" ON "Invoices" (get_itemcode("Blob2")) WHERE get_itemcode("Blob2") IS NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
-- Rename column | ||
ALTER TABLE "Payouts" RENAME COLUMN "PaymentMethodId" TO "PayoutMethodId"; | ||
|
||
-- Add Currency column, guessed from the PaymentMethodId | ||
ALTER TABLE "Payouts" ADD COLUMN "Currency" TEXT; | ||
UPDATE "Payouts" SET | ||
"Currency" = split_part("PayoutMethodId", '_', 1), | ||
"PayoutMethodId"= | ||
CASE | ||
WHEN split_part("PayoutMethodId", '_', 2) = 'LightningLike' THEN split_part("PayoutMethodId", '_', 1) || '-LN' | ||
ELSE split_part("PayoutMethodId", '_', 1) || '-CHAIN' | ||
END; | ||
ALTER TABLE "Payouts" ALTER COLUMN "Currency" SET NOT NULL; | ||
|
||
-- Remove Currency and Limit from PullPayment Blob, and put it into the columns in the table | ||
ALTER TABLE "PullPayments" ADD COLUMN "Currency" TEXT; | ||
UPDATE "PullPayments" SET "Currency" = "Blob"->>'Currency'; | ||
ALTER TABLE "PullPayments" ALTER COLUMN "Currency" SET NOT NULL; | ||
ALTER TABLE "PullPayments" ADD COLUMN "Limit" NUMERIC; | ||
UPDATE "PullPayments" SET "Limit" = ("Blob"->>'Limit')::NUMERIC; | ||
ALTER TABLE "PullPayments" ALTER COLUMN "Limit" SET NOT NULL; | ||
|
||
-- Remove unused properties, rename SupportedPaymentMethods, and fix legacy payment methods IDs | ||
UPDATE "PullPayments" SET | ||
"Blob" = jsonb_set( | ||
"Blob" - 'SupportedPaymentMethods' - 'Limit' - 'Currency' - 'Period', | ||
'{SupportedPayoutMethods}', | ||
(SELECT jsonb_agg(to_jsonb( | ||
CASE | ||
WHEN split_part(value::TEXT, '_', 2) = 'LightningLike' THEN split_part(value::TEXT, '_', 1) || '-LN' | ||
ELSE split_part(value::TEXT, '_', 1) || '-CHAIN' | ||
END)) | ||
FROM jsonb_array_elements_text("Blob"->'SupportedPaymentMethods') AS value | ||
)); | ||
|
||
--Remove "Amount" and "CryptoAmount" from Payout Blob, and put it into the columns in the table | ||
-- Respectively "OriginalAmount" and "Amount" | ||
|
||
ALTER TABLE "Payouts" ADD COLUMN "Amount" NUMERIC; | ||
UPDATE "Payouts" SET "Amount" = ("Blob"->>'CryptoAmount')::NUMERIC; | ||
|
||
ALTER TABLE "Payouts" ADD COLUMN "OriginalAmount" NUMERIC; | ||
UPDATE "Payouts" SET "OriginalAmount" = ("Blob"->>'Amount')::NUMERIC; | ||
ALTER TABLE "Payouts" ALTER COLUMN "OriginalAmount" SET NOT NULL; | ||
|
||
ALTER TABLE "Payouts" ADD COLUMN "OriginalCurrency" TEXT; | ||
|
||
|
||
UPDATE "Payouts" p | ||
SET | ||
"OriginalCurrency" = "Currency", | ||
"Blob" = "Blob" - 'Amount' - 'CryptoAmount' | ||
WHERE "PullPaymentDataId" IS NULL AND "OriginalCurrency" IS NULL; | ||
|
||
UPDATE "Payouts" p | ||
SET | ||
"OriginalCurrency" = pp."Currency" | ||
FROM "PullPayments" pp | ||
WHERE "OriginalCurrency" IS NULL AND pp."Id"=p."PullPaymentDataId"; | ||
|
||
ALTER TABLE "Payouts" ALTER COLUMN "OriginalCurrency" SET NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
BTCPayServer.Data/Migrations/20240520042729_payoutsmigration.cs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
BTCPayServer.Data/Migrations/20240826065950_removeinvoicecols.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using BTCPayServer.Data; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace BTCPayServer.Migrations | ||
{ | ||
[DbContext(typeof(ApplicationDbContext))] | ||
[Migration("20240826065950_removeinvoicecols")] | ||
[DBScript("001.InvoiceFunctions.sql")] | ||
public partial class removeinvoicecols : DBScriptsMigration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropIndex( | ||
name: "IX_Invoices_OrderId", | ||
table: "Invoices"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "ItemCode", | ||
table: "Invoices"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "OrderId", | ||
table: "Invoices"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "CustomerEmail", | ||
table: "Invoices"); | ||
base.Up(migrationBuilder); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
BTCPayServer.Data/Migrations/20240827034505_migratepayouts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using BTCPayServer.Data; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace BTCPayServer.Migrations | ||
{ | ||
[DbContext(typeof(ApplicationDbContext))] | ||
[Migration("20240827034505_migratepayouts")] | ||
[DBScript("002.RefactorPayouts.sql")] | ||
public partial class migratepayouts : DBScriptsMigration | ||
{ | ||
} | ||
} |
Oops, something went wrong.