-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add backup table for materialized view (#517)
Co-authored-by: amateima <[email protected]>
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 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
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"`); | ||
} | ||
} |