<?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 Version20241220184438 extends AbstractMigration
{
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 `notification` n
LEFT JOIN `ws_document` d ON n.document_id = d.id
LEFT JOIN `ws_event` e ON n.event_id = e.id
LEFT JOIN `ws_task` t ON n.task_id = t.id
SET n.stream_id = COALESCE(d.stream_id, e.stream_id, t.stream_id)
WHERE n.stream_id IS NULL
AND n.type != 'system'
");
$this->addSql("
UPDATE `notification` n
LEFT JOIN `w_stream` s ON n.stream_id = s.id
SET n.workspace_id = COALESCE(s.workspace_id)
WHERE n.workspace_id IS NULL
AND n.type != 'system'
");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("
UPDATE `notification` n
SET n.stream_id = NULL
WHERE n.type IN ('document', 'event', 'task')
");
$this->addSql("
UPDATE `notification` n
SET n.workspace_id = NULL
WHERE n.type IN ('stream', 'document', 'event', 'task')
");
}
}