-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
326 additions
and
81 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
26 changes: 26 additions & 0 deletions
26
prisma/migrations/20241016171557_blinkreceive/migration.sql
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,26 @@ | ||
-- AlterEnum | ||
ALTER TYPE "WalletType" ADD VALUE 'BLINK'; | ||
|
||
-- CreateTable | ||
CREATE TABLE "WalletBlink" ( | ||
"id" SERIAL NOT NULL, | ||
"walletId" INTEGER NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"apiKeyRecv" TEXT NOT NULL, | ||
"currencyRecv" TEXT, | ||
|
||
CONSTRAINT "WalletBlink_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "WalletBlink_walletId_key" ON "WalletBlink"("walletId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "WalletBlink" ADD CONSTRAINT "WalletBlink_walletId_fkey" FOREIGN KEY ("walletId") REFERENCES "Wallet"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
|
||
-- Update wallet json | ||
CREATE TRIGGER wallet_blink_as_jsonb | ||
AFTER INSERT OR UPDATE ON "WalletBlink" | ||
FOR EACH ROW EXECUTE PROCEDURE wallet_wallet_type_as_jsonb(); |
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
28 changes: 28 additions & 0 deletions
28
prisma/migrations/20241101151907_fix_territory_revenue/migration.sql
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,28 @@ | ||
-- fix revenue for users who have multiple revenue entries for the same day | ||
WITH revenue_days AS ( | ||
SELECT coalesce(sum(msats), 0) as revenue_msats, "userId", created_at | ||
FROM "SubAct" | ||
WHERE type = 'REVENUE' | ||
GROUP BY "userId", created_at | ||
HAVING COUNT(*) > 1 | ||
), | ||
revenue_total AS ( | ||
SELECT coalesce(sum(revenue_msats), 0) as revenue_msats, "userId" | ||
FROM revenue_days | ||
GROUP BY "userId" | ||
) | ||
UPDATE users SET msats = users.msats + revenue_total.revenue_msats | ||
FROM revenue_total | ||
WHERE users.id = revenue_total."userId"; | ||
|
||
-- fix stacked msats for users who have territory revenue | ||
-- prior to this, we were not updating stacked msats for territory revenue | ||
WITH territory_revenue AS ( | ||
SELECT coalesce(sum(msats), 0) as revenue_msats, "userId" | ||
FROM "SubAct" | ||
WHERE type = 'REVENUE' | ||
GROUP BY "userId" | ||
) | ||
UPDATE users SET "stackedMsats" = users."stackedMsats" + territory_revenue.revenue_msats | ||
FROM territory_revenue | ||
WHERE users.id = territory_revenue."userId"; |
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
Oops, something went wrong.