import { MigrationInterface, QueryRunner } from 'typeorm';

export class fixMessageToTeamTemplate1717472434321
  implements MigrationInterface
{
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
                DELETE FROM message_template WHERE name_template = 'message_to_team'
            `);
    await queryRunner.query(
      `INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
            VALUES ('message_to_team', 'ru', 'IMS Creators - уведомление о сообщении команде проекта',
                '<p>Проект: {{PROJECT_NAME}} ({{PROJECT_LINK}})</p>
                <p>Отправитель: {{USER_NAME}} ({{USER_EMAIL}})</p>
                <p>Тема: {{USER_SUBJECT}}</p>
                <br></br>
                <p>{{!html:USER_MESSAGE}}</p>'
            );`,
    );

    await queryRunner.query(`
            INSERT INTO message_template (name_template,language_template,subject_template,text_template) 
            VALUES ('message_to_team', 'en', 'IMS Creators - notification to team of the project',
                '<p>Project: {{PROJECT_NAME}} ({{PROJECT_LINK}})</p>
                <p>Sender: {{USER_NAME}} ({{USER_EMAIL}})</p>
                <p>Subject: {{USER_SUBJECT}}</p>
                <br></br>
                <p>{{!html:USER_MESSAGE}}</p>'
            );
        `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            DELETE FROM message_template WHERE name_template = 'message_to_team'
        `);
  }
}
