-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fix unique index on donation entity
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 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,27 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { logger } from '../src/utils/logger'; | ||
|
||
export class modifyDonationUniquenessIndex1701916750562 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`DROP INDEX IF EXISTS "UQ_c9db9fd133378af80c3521bb146";`, | ||
); | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX IF NOT EXISTS "UQ_c9db9fd133378af80c3521bb146" | ||
ON public.donation (transactionId, toWalletAddress, currency) | ||
WHERE transactionId IS NOT NULL; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`DROP INDEX IF EXISTS "UQ_c9db9fd133378af80c3521bb146";`, | ||
); | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX IF NOT EXISTS "UQ_c9db9fd133378af80c3521bb146" | ||
ON public.donation (transactionId, toWalletAddress, currency) | ||
`); | ||
} | ||
} |
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