<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251023010406 extends AbstractMigration
{
public const WIDGET_ID_1 = 44; // shared-unread-messages
public const WIDGET_ID_2 = 45; // shared-unread-feeds
public const WIDGET_ID_3 = 46; // shared-unread-streams
public const WIDGET_ID_4 = 47; // shared-unread-projects
public const WIDGET_ID_5 = 48; // shared-open-issues
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('
UPDATE widget
SET category = "Cards",
token = REPLACE(token, "shared-", "cards-")
WHERE category = "Shared"
');
/** @var string $idList */
$idList = $this->idListSql();
$this->addSql(sprintf(
'
UPDATE widget
SET name = REPLACE(name, "Sales ", "")
WHERE id IN (%s)
',
$idList
));
$this->addSql(sprintf('UPDATE widget SET name = REPLACE(name, "Feeds", "Buzz") WHERE id = %d', WIDGET_ID_2));
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('
UPDATE widget
SET category = "Shared",
token = REPLACE(token, "cards-", "shared-")
WHERE category = "Cards"
');
/** @var string $idList */
$idList = $this->idListSql();
$this->addSql(sprintf(
'
UPDATE widget
SET name = CONCAT("Sales ", name)
WHERE id IN (%s)
',
$idList
));
$this->addSql(sprintf('UPDATE widget SET name = REPLACE(name, "Buzz", "Feeds") WHERE id = %d', WIDGET_ID_2));
}
/**
* @return string
*/
private function idListSql(): string
{
return implode(',', array_map('intval', [
self::WIDGET_ID_1,
self::WIDGET_ID_2,
self::WIDGET_ID_3,
self::WIDGET_ID_4,
self::WIDGET_ID_5,
]));
}
}