Skip to content

Commit

Permalink
feat: add backup table for materialized view (#517)
Browse files Browse the repository at this point in the history
Co-authored-by: amateima <[email protected]>
  • Loading branch information
amateima and amateima authored Feb 5, 2025
1 parent 0ad5467 commit 5edfdc4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions migrations/1736706626172-DepositReferraInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class DepositReferraInfo1736706626172 implements MigrationInterface {
name = "DepositReferraInfo1736706626172";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
create table deposit_referral_info
as select * from deposits_mv
with no data;
`);
await queryRunner.query(`
CREATE UNIQUE INDEX "UK_dri_depositId_sourceChainId"
ON deposit_referral_info ("depositId", "sourceChainId");
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "UK_dri_depositId_sourceChainId"`);
await queryRunner.query(`DROP TABLE "deposit_referral_info"`);
}
}

0 comments on commit 5edfdc4

Please sign in to comment.