import { MigrationInterface, QueryRunner } from 'typeorm';

export class GameMatchMisses1000000000006 implements MigrationInterface {
  name = 'GameMatchMisses1000000000006';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      CREATE TABLE IF NOT EXISTS "game_match_misses" (
        "processKey"  TEXT PRIMARY KEY NOT NULL,
        "processName" TEXT NOT NULL,
        "missedAt"    INTEGER NOT NULL,
        "expiresAt"   INTEGER NOT NULL
      )
    `);
    await queryRunner.query(`
      CREATE INDEX IF NOT EXISTS "idx_game_match_misses_expiresAt"
      ON "game_match_misses" ("expiresAt")
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE IF EXISTS "game_match_misses"`);
  }
}
