import { MigrationInterface, QueryRunner } from 'typeorm';

export class updateMessageTemplates1703226414653 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            DELETE FROM message_template WHERE name_template = 'task_assignment_notification'
        `);
    await queryRunner.query(
      `INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
              VALUES ('task_assignment_notification', 'ru', 'IMS Creators - уведомление о последних действиях в проекте {{PROJECT_NAME}}',
                  '<h1>Действия за последнее время в проекте {{PROJECT_NAME}}</h1>
                  <p>Здравствуйте!</p>
                  <p>Действия за последнее время в проекте:</p>
                  <p>{{!html:PROJECT_ACTIONS_HTML}}</p>'
              );`,
    );

    await queryRunner.query(`
              INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
              VALUES ('task_assignment_notification', 'en', 'IMS Creators - last actions notification in the project {{PROJECT_NAME}}',
                  '<h1>Recent activities in the project {{PROJECT_NAME}}</h1>
                  <p>Hello!</p>
                  <p>Recent activities in the project:</p>
                  <p>{{!html:PROJECT_ACTIONS_HTML}}</p>'
              );
          `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            DELETE FROM message_template WHERE name_template = 'task_assignment_notification'
        `);
    await queryRunner.query(
      `INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
              VALUES ('task_assignment_notification', 'ru', 'IMS Creators - уведомление о последних действиях в проекте {{PROJECT_NAME}}',
                  '<h1>Действия за последнее время в проекте {{PROJECT_NAME}}</h1>
                  <p>Здравствуйте!</p>
                  <p>Действия за последнее время в проекте:</p>
                  <p>{{PROJECT_ACTIONS}}</p>'
              );`,
    );

    await queryRunner.query(`
              INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
              VALUES ('task_assignment_notification', 'en', 'IMS Creators - last actions notification in the project {{PROJECT_NAME}}',
                  '<h1>Recent activities in the project {{PROJECT_NAME}}</h1>
                  <p>Hello!</p>
                  <p>Recent activities in the project:</p>
                  <p>{{PROJECT_ACTIONS}}</p>'
              );
          `);
  }
}
