portal.mkgtu.ru/common/migrations/db/m220609_145640_fix_tooltip_...

72 lines
2.2 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use common\components\LikeQueryManager;
use common\components\Migration\MigrationWithDefaultOptions;
use yii\db\Query;
use yii\helpers\Console;
class m220609_145640_fix_tooltip_text extends MigrationWithDefaultOptions
{
private const TN = '{{%text_settings}}';
public function safeUp()
{
$badTexts = (new Query())
->select(['id'])
->from(self::TN)
->where([LikeQueryManager::getActionName(), 'tooltip_description', 'личного кабинет поступающего'])
->all();
if (empty($badTexts)) {
echo Console::ansiFormat(
'Не найдены данные требующие обновления',
[Console::BG_GREEN, Console::FG_BLACK]
) . PHP_EOL;
return true;
}
foreach ($badTexts as $badText) {
$this->update(
self::TN,
['tooltip_description' => 'Отображается на стартовой странице личного кабинета поступающего перед заполнением анкеты.'],
['id' => $badText['id']]
);
}
}
public function safeDown()
{
$badTexts = (new Query())
->select(['id'])
->from(self::TN)
->where(['=', 'tooltip_description', 'Отображается на стартовой странице личного кабинета поступающего перед заполнением анкеты.'])
->all();
if (empty($badTexts)) {
echo Console::ansiFormat(
'Не найдены данные требующие восстановления',
[Console::BG_GREEN, Console::FG_BLACK]
) . PHP_EOL;
return true;
}
foreach ($badTexts as $badText) {
$this->update(
self::TN,
['tooltip_description' => 'Отображается на стартовой странице личного кабинет поступающего перед заполнением анкеты.'],
['id' => $badText['id']]
);
}
}
}