forked from PluralFlux/PluralFlux
Delete duplicate members migration (#33)
* add migration to delete duplicates that currently exist in the db * added a name attribute for consistency --------- Co-authored-by: Aster Fialla <asterfialla@gmail.com>
This commit is contained in:
17
database/migrations/1772825438973-delete-duplicates.ts
Normal file
17
database/migrations/1772825438973-delete-duplicates.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class DeleteDuplicates1772825438973 implements MigrationInterface {
|
||||||
|
name= "DeleteDuplicates1772825438973"
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DELETE
|
||||||
|
FROM "Member" a USING "Member" b
|
||||||
|
WHERE a.id
|
||||||
|
> b.id
|
||||||
|
AND a.name = b.name
|
||||||
|
AND a.userid = b.userid;`)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user