import { MigrationInterface, QueryRunner } from 'typeorm';

export class addMessageToTeamTemplate1706008466661
  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 - уведомление о сообщении команде проекта {{PROJECT_NAME}}',
            '<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 {{PROJECT_NAME}}',
            '<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'
    `);
  }
}
