<?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 Version20240422223603 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('CREATE TABLE ws_document (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', creator_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', stream_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', type VARCHAR(255) DEFAULT NULL, completed INT DEFAULT NULL, body LONGTEXT DEFAULT NULL, interactions INT DEFAULT NULL, last_contacted DATETIME DEFAULT NULL, name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, INDEX IDX_B14013BF61220EA6 (creator_id), INDEX idx_steam (stream_id), INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE ws_document_user (document_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', user_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_8DC9D3DFC33F7837 (document_id), INDEX IDX_8DC9D3DFA76ED395 (user_id), PRIMARY KEY(document_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE ws_document ADD CONSTRAINT FK_B14013BF61220EA6 FOREIGN KEY (creator_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE ws_document ADD CONSTRAINT FK_B14013BFD0ED463E FOREIGN KEY (stream_id) REFERENCES w_stream (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE ws_document_user ADD CONSTRAINT FK_8DC9D3DFC33F7837 FOREIGN KEY (document_id) REFERENCES ws_document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE ws_document_user ADD CONSTRAINT FK_8DC9D3DFA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE notification ADD document_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAC33F7837 FOREIGN KEY (document_id) REFERENCES ws_document (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX idx_type ON notification (type)');
$this->addSql('CREATE INDEX idx_document ON notification (document_id)');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_bf5476ca82d40a1f TO idx_workspace');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_bf5476cad0ed463e TO idx_steam');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_bf5476ca71f7e88b TO idx_event');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_bf5476ca8db60186 TO idx_task');
$this->addSql('ALTER TABLE user ADD notify_when_document_assigned LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE ws_comment ADD document_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE ws_comment ADD CONSTRAINT FK_BB2F65FFC33F7837 FOREIGN KEY (document_id) REFERENCES ws_document (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX idx_type ON ws_comment (type)');
$this->addSql('CREATE INDEX idx_document ON ws_comment (document_id)');
$this->addSql('ALTER TABLE ws_file ADD document_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE ws_file ADD CONSTRAINT FK_2E8DFFA2C33F7837 FOREIGN KEY (document_id) REFERENCES ws_document (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX idx_type ON ws_file (type)');
$this->addSql('CREATE INDEX idx_document ON ws_file (document_id)');
$this->addSql('UPDATE user SET notify_when_document_assigned = \'a:2:{i:0;s:5:"email";i:1;s:5:"inapp";}\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_BF5476CAC33F7837');
$this->addSql('ALTER TABLE ws_comment DROP FOREIGN KEY FK_BB2F65FFC33F7837');
$this->addSql('ALTER TABLE ws_file DROP FOREIGN KEY FK_2E8DFFA2C33F7837');
$this->addSql('ALTER TABLE ws_document DROP FOREIGN KEY FK_B14013BF61220EA6');
$this->addSql('ALTER TABLE ws_document DROP FOREIGN KEY FK_B14013BFD0ED463E');
$this->addSql('ALTER TABLE ws_document_user DROP FOREIGN KEY FK_8DC9D3DFC33F7837');
$this->addSql('ALTER TABLE ws_document_user DROP FOREIGN KEY FK_8DC9D3DFA76ED395');
$this->addSql('DROP TABLE ws_document');
$this->addSql('DROP TABLE ws_document_user');
$this->addSql('DROP INDEX idx_type ON notification');
$this->addSql('DROP INDEX idx_document ON notification');
$this->addSql('ALTER TABLE notification DROP document_id');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_event TO IDX_BF5476CA71F7E88B');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_workspace TO IDX_BF5476CA82D40A1F');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_steam TO IDX_BF5476CAD0ED463E');
$this->addSql('ALTER TABLE notification RENAME INDEX idx_task TO IDX_BF5476CA8DB60186');
$this->addSql('ALTER TABLE user DROP notify_when_document_assigned');
$this->addSql('DROP INDEX idx_type ON ws_comment');
$this->addSql('DROP INDEX idx_document ON ws_comment');
$this->addSql('ALTER TABLE ws_comment DROP document_id');
$this->addSql('DROP INDEX idx_type ON ws_file');
$this->addSql('DROP INDEX idx_document ON ws_file');
$this->addSql('ALTER TABLE ws_file DROP document_id');
}
}