import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "store_value" ("key" varchar PRIMARY KEY NOT NULL, "value" text NOT NULL)`,
      undefined
    );
    await queryRunner.query(
      `CREATE TABLE "query-result-cache" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "identifier" varchar, "time" bigint NOT NULL, "duration" integer NOT NULL, "query" text NOT NULL, "result" text NOT NULL)`,
      undefined
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "query-result-cache"`, undefined);
    await queryRunner.query(`DROP TABLE "store_value"`, undefined);
  }
}
