migrations/Version20251023010406.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20251023010406 extends AbstractMigration
  10. {
  11.     public const WIDGET_ID_1 44// shared-unread-messages
  12.     public const WIDGET_ID_2 45// shared-unread-feeds
  13.     public const WIDGET_ID_3 46// shared-unread-streams
  14.     public const WIDGET_ID_4 47// shared-unread-projects
  15.     public const WIDGET_ID_5 48// shared-open-issues
  16.     public function getDescription(): string
  17.     {
  18.         return '';
  19.     }
  20.     public function up(Schema $schema): void
  21.     {
  22.         // this up() migration is auto-generated, please modify it to your needs
  23.         $this->addSql('
  24.             UPDATE widget
  25.              SET category = "Cards",
  26.                  token = REPLACE(token, "shared-", "cards-")
  27.              WHERE category = "Shared"
  28.         ');
  29.         /** @var string $idList */
  30.         $idList $this->idListSql();
  31.         $this->addSql(sprintf(
  32.             '
  33.                 UPDATE widget
  34.                 SET name = REPLACE(name, "Sales ", "")
  35.                 WHERE id IN (%s)
  36.             ',
  37.             $idList
  38.         ));
  39.         $this->addSql(sprintf('UPDATE widget SET name = REPLACE(name, "Feeds", "Buzz") WHERE id = %d'WIDGET_ID_2));
  40.     }
  41.     public function down(Schema $schema): void
  42.     {
  43.         // this down() migration is auto-generated, please modify it to your needs
  44.         $this->addSql('
  45.             UPDATE widget
  46.              SET category = "Shared",
  47.                  token = REPLACE(token, "cards-", "shared-")
  48.              WHERE category = "Cards"
  49.         ');
  50.         /** @var string $idList */
  51.         $idList $this->idListSql();
  52.         $this->addSql(sprintf(
  53.             '
  54.                 UPDATE widget
  55.                 SET name = CONCAT("Sales ", name)
  56.                 WHERE id IN (%s)
  57.             ',
  58.             $idList
  59.         ));
  60.         $this->addSql(sprintf('UPDATE widget SET name = REPLACE(name, "Buzz", "Feeds") WHERE id = %d'WIDGET_ID_2));
  61.     }
  62.     /**
  63.      * @return string
  64.      */
  65.     private function idListSql(): string
  66.     {
  67.         return implode(','array_map('intval', [
  68.             self::WIDGET_ID_1,
  69.             self::WIDGET_ID_2,
  70.             self::WIDGET_ID_3,
  71.             self::WIDGET_ID_4,
  72.             self::WIDGET_ID_5,
  73.         ]));
  74.     }
  75. }