migrations/Version20250924152449.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 Version20250924152449 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $rows $this->connection->fetchAllAssociative('SELECT id, body FROM customer_interview_note WHERE body LIKE \'%<span class="text-editor-merge-field is-reference%\'');
  19.         foreach ($rows as $row) {
  20.             $updatedBody preg_replace(
  21.                 '#<span class="text-editor-merge-field-container"><span class="text-editor-merge-field is-reference" data-href="([^"]+)" contenteditable="false">(\#{0,1}\s*\d+)</span></span>#',
  22.                 '<a href="$1">$2</a>',
  23.                 $row['body']
  24.             );
  25.             if ($updatedBody !== $row['body']) {
  26.                 $this->addSql('UPDATE customer_interview_note SET body = ? WHERE id = ?', [$updatedBody$row['id']]);
  27.             }
  28.         }
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         // this migration is not reversible.
  34.         // the <a href> links will be kept as links and not reverted to <span>.
  35.     }
  36. }