-
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.
fix: add DB migration for empty block transfers
- Loading branch information
1 parent
5eeda07
commit ee255ed
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/worker/src/migrations/1699955766418-SetTransferTypeForEmptyBlockTransfers.ts
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,22 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class SetTransferTypeForEmptyBlockTransfers1699955766418 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
WITH "updatedTransferNumbers" AS | ||
( | ||
UPDATE transfers | ||
SET "type" = 'transfer', "isFeeOrRefund" = false, "isInternal" = true, "updatedAt" = CURRENT_TIMESTAMP | ||
WHERE "transactionHash" IS NULL AND "isInternal" = false | ||
RETURNING number | ||
) | ||
UPDATE "addressTransfers" | ||
SET "isFeeOrRefund" = false, "isInternal" = true, "updatedAt" = CURRENT_TIMESTAMP | ||
FROM "updatedTransferNumbers" | ||
WHERE "transferNumber" = "updatedTransferNumbers"."number" | ||
`); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
public async down(): Promise<void> {} | ||
} |