migrations/Version20241220184438.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 Version20241220184438 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.         $this->addSql("
  19.             UPDATE `notification` n
  20.             LEFT JOIN `ws_document` d ON n.document_id = d.id
  21.             LEFT JOIN `ws_event` e ON n.event_id = e.id
  22.             LEFT JOIN `ws_task` t ON n.task_id = t.id
  23.             SET n.stream_id = COALESCE(d.stream_id, e.stream_id, t.stream_id)
  24.             WHERE n.stream_id IS NULL
  25.               AND n.type != 'system'
  26.         ");
  27.         $this->addSql("
  28.             UPDATE `notification` n
  29.             LEFT JOIN `w_stream` s ON n.stream_id = s.id
  30.             SET n.workspace_id = COALESCE(s.workspace_id)
  31.             WHERE n.workspace_id IS NULL
  32.               AND n.type != 'system'
  33.         ");
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         // this down() migration is auto-generated, please modify it to your needs
  38.         $this->addSql("
  39.             UPDATE `notification` n
  40.             SET n.stream_id = NULL
  41.             WHERE n.type IN ('document', 'event', 'task')
  42.         ");
  43.         $this->addSql("
  44.             UPDATE `notification` n
  45.             SET n.workspace_id = NULL
  46.             WHERE n.type IN ('stream', 'document', 'event', 'task')
  47.         ");
  48.     }
  49. }