/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class VoximplantScenarios1698421539770 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      create table voximplant_scenario_entity (
        id integer generated by default as identity,
        account_id integer not null,
        scenario_type character varying not null,
        contact_id integer,
        deal_id integer,
        board_id integer,
        owner_id integer,
        primary key (id),
        foreign key (account_id) references account(id) on delete cascade,
        foreign key (contact_id) references entity_type(id) on delete cascade,
        foreign key (deal_id) references entity_type(id) on delete cascade,
        foreign key (board_id) references board(id) on delete cascade,
        foreign key (owner_id) references users(id) on delete cascade
      );

      create table voximplant_scenario_note (
        id integer generated by default as identity,
        account_id integer not null,
        scenario_type character varying not null,
        note_text character varying not null,
        primary key (id),
        foreign key (account_id) references account(id) on delete cascade
      );

      create table voximplant_scenario_task (
        id integer generated by default as identity,
        account_id integer not null,
        scenario_type character varying not null,
        create_activity boolean,
        activity_type_id integer,
        activity_text character varying,
        activity_duration integer,
        activity_owner_id integer,
        create_task boolean,
        task_title character varying,
        task_text character varying,
        task_duration integer,
        task_owner_id integer,
        primary key (id),
        foreign key (account_id) references account(id) on delete cascade,
        foreign key (activity_type_id) references activity_type(id) on delete cascade,
        foreign key (activity_owner_id) references users(id) on delete cascade,
        foreign key (task_owner_id) references users(id) on delete cascade
      );
    `);
  }

  public async down(_queryRunner: QueryRunner): Promise<void> {}
}
