Skip to content

Commit

Permalink
fix: add DB migration for empty block transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Nov 14, 2023
1 parent 5eeda07 commit ee255ed
Showing 1 changed file with 22 additions and 0 deletions.
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> {}
}

0 comments on commit ee255ed

Please sign in to comment.