import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TABLE "report_bookmark" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "group_name" character varying NOT NULL, "unique_name" character varying NOT NULL, "label" character varying NOT NULL, "applied" boolean DEFAULT false, "configuration" json, CONSTRAINT "PK_d72aa68a7ee505edf4f3e156946" PRIMARY KEY ("id"))`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."export_report_history_status_enum" AS ENUM('processing', 'done', 'failed', 'cancel')`,
    );
    await queryRunner.query(
      `CREATE TABLE "export_report_history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "group_name" character varying NOT NULL, "unique_name" character varying NOT NULL, "label" character varying NOT NULL, "file_name" character varying NOT NULL, "file_url" character varying, "total_data" integer NOT NULL DEFAULT '0', "processing_data" integer NOT NULL DEFAULT '0', "status" "public"."export_report_history_status_enum", "last_process_offset" integer NOT NULL DEFAULT '0', "last_process_limit" integer NOT NULL DEFAULT '0', "total_resume" integer NOT NULL DEFAULT '0', "last_resume_created_at" bigint, "query_export" character varying, "canceled_at" bigint, CONSTRAINT "PK_07a632c94dca0728ad1b51ed65c" PRIMARY KEY ("id"))`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "export_report_history"`);
    await queryRunner.query(
      `DROP TYPE "public"."export_report_history_status_enum"`,
    );
    await queryRunner.query(`DROP TABLE "report_bookmark"`);
  }
}
