Skip to content

Commit 1c05d70

Browse files
committed
feat: defaultFeedId index
fixes fk constraint slowness on deletion
1 parent b6db25f commit 1c05d70

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/entity/user/User.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ export class User {
255255
@Column({ type: 'boolean', default: true })
256256
followNotifications: boolean;
257257

258+
@Index('IDX_user_defaultFeedId')
258259
@Column({ type: 'text', nullable: true })
259260
defaultFeedId?: string | null;
260261

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class UserDefaultFeedId1782289467831 implements MigrationInterface {
4+
name = 'UserDefaultFeedId1782289467831';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE INDEX IF NOT EXISTS "IDX_user_defaultFeedId" ON "user" ("defaultFeedId") `,
9+
);
10+
}
11+
12+
public async down(queryRunner: QueryRunner): Promise<void> {
13+
await queryRunner.query(`DROP INDEX IF EXISTS "IDX_user_defaultFeedId"`);
14+
}
15+
}

0 commit comments

Comments
 (0)