From 37cdb2e66b0c691007ca9e044440163f0496f84b Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Mon, 4 Jan 2021 02:28:11 +0100 Subject: [PATCH] Add index to expires_at --- .../migrations/1608753440716-CreateTempBansTable.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/migrations/1608753440716-CreateTempBansTable.ts b/backend/src/migrations/1608753440716-CreateTempBansTable.ts index 7599506e..7345d34c 100644 --- a/backend/src/migrations/1608753440716-CreateTempBansTable.ts +++ b/backend/src/migrations/1608753440716-CreateTempBansTable.ts @@ -1,8 +1,8 @@ -import { MigrationInterface, QueryRunner, Table } from "typeorm"; +import { MigrationInterface, QueryRunner, Table, TableIndex } from "typeorm"; export class CreateTempBansTable1608753440716 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { - await queryRunner.createTable( + const table = await queryRunner.createTable( new Table({ name: "tempbans", columns: [ @@ -31,6 +31,12 @@ export class CreateTempBansTable1608753440716 implements MigrationInterface { ], }), ); + queryRunner.createIndex( + "tempbans", + new TableIndex({ + columnNames: ["expires_at"], + }), + ); } public async down(queryRunner: QueryRunner): Promise {