<?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 Version20231020175154 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('DELETE FROM wsc_option');
$this->addSql('CREATE TABLE wsc_poll (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', comment_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_8FEC8DE1F8697D13 (comment_id), INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE wsc_poll ADD CONSTRAINT FK_8FEC8DE1F8697D13 FOREIGN KEY (comment_id) REFERENCES ws_comment (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE ws_comment ADD poll_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE ws_comment ADD CONSTRAINT FK_BB2F65FF3C947C0F FOREIGN KEY (poll_id) REFERENCES wsc_poll (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_BB2F65FF3C947C0F ON ws_comment (poll_id)');
$this->addSql('ALTER TABLE wsc_option DROP FOREIGN KEY FK_5E8C9692F8697D13');
$this->addSql('DROP INDEX IDX_5E8C9692F8697D13 ON wsc_option');
$this->addSql('ALTER TABLE wsc_option CHANGE comment_id poll_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE wsc_option ADD CONSTRAINT FK_5E8C96923C947C0F FOREIGN KEY (poll_id) REFERENCES wsc_poll (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_5E8C96923C947C0F ON wsc_option (poll_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DELETE FROM wsc_option');
$this->addSql('ALTER TABLE ws_comment DROP FOREIGN KEY FK_BB2F65FF3C947C0F');
$this->addSql('ALTER TABLE wsc_option DROP FOREIGN KEY FK_5E8C96923C947C0F');
$this->addSql('ALTER TABLE wsc_poll DROP FOREIGN KEY FK_8FEC8DE1F8697D13');
$this->addSql('DROP TABLE wsc_poll');
$this->addSql('DROP INDEX IDX_BB2F65FF3C947C0F ON ws_comment');
$this->addSql('ALTER TABLE ws_comment DROP poll_id');
$this->addSql('DROP INDEX IDX_5E8C96923C947C0F ON wsc_option');
$this->addSql('ALTER TABLE wsc_option CHANGE poll_id comment_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE wsc_option ADD CONSTRAINT FK_5E8C9692F8697D13 FOREIGN KEY (comment_id) REFERENCES ws_comment (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_5E8C9692F8697D13 ON wsc_option (comment_id)');
}
}