diff --git a/src/notifications/migrations/AddNotificationCompositeIndex.ts b/src/notifications/migrations/AddNotificationCompositeIndex.ts new file mode 100644 index 00000000..c3469cbe --- /dev/null +++ b/src/notifications/migrations/AddNotificationCompositeIndex.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner, TableIndex } from 'typeorm'; + +export class AddNotificationCompositeIndex1700000000000 implements MigrationInterface { + name = 'AddNotificationCompositeIndex1700000000000'; + + async up(queryRunner: QueryRunner): Promise { + await queryRunner.createIndex( + 'notifications', + new TableIndex({ + name: 'IDX_notifications_user_type_status_created', + columnNames: ['userId', 'type', 'status', 'createdAt'], + }), + ); + } + + async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropIndex('notifications', 'IDX_notifications_user_type_status_created'); + } +}