migrations/Version20231020175154.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 Version20231020175154 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('DELETE FROM wsc_option');
  19.         $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');
  20.         $this->addSql('ALTER TABLE wsc_poll ADD CONSTRAINT FK_8FEC8DE1F8697D13 FOREIGN KEY (comment_id) REFERENCES ws_comment (id) ON DELETE CASCADE');
  21.         $this->addSql('ALTER TABLE ws_comment ADD poll_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  22.         $this->addSql('ALTER TABLE ws_comment ADD CONSTRAINT FK_BB2F65FF3C947C0F FOREIGN KEY (poll_id) REFERENCES wsc_poll (id) ON DELETE SET NULL');
  23.         $this->addSql('CREATE INDEX IDX_BB2F65FF3C947C0F ON ws_comment (poll_id)');
  24.         $this->addSql('ALTER TABLE wsc_option DROP FOREIGN KEY FK_5E8C9692F8697D13');
  25.         $this->addSql('DROP INDEX IDX_5E8C9692F8697D13 ON wsc_option');
  26.         $this->addSql('ALTER TABLE wsc_option CHANGE comment_id poll_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  27.         $this->addSql('ALTER TABLE wsc_option ADD CONSTRAINT FK_5E8C96923C947C0F FOREIGN KEY (poll_id) REFERENCES wsc_poll (id) ON DELETE CASCADE');
  28.         $this->addSql('CREATE INDEX IDX_5E8C96923C947C0F ON wsc_option (poll_id)');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('DELETE FROM wsc_option');
  34.         $this->addSql('ALTER TABLE ws_comment DROP FOREIGN KEY FK_BB2F65FF3C947C0F');
  35.         $this->addSql('ALTER TABLE wsc_option DROP FOREIGN KEY FK_5E8C96923C947C0F');
  36.         $this->addSql('ALTER TABLE wsc_poll DROP FOREIGN KEY FK_8FEC8DE1F8697D13');
  37.         $this->addSql('DROP TABLE wsc_poll');
  38.         $this->addSql('DROP INDEX IDX_BB2F65FF3C947C0F ON ws_comment');
  39.         $this->addSql('ALTER TABLE ws_comment DROP poll_id');
  40.         $this->addSql('DROP INDEX IDX_5E8C96923C947C0F ON wsc_option');
  41.         $this->addSql('ALTER TABLE wsc_option CHANGE poll_id comment_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
  42.         $this->addSql('ALTER TABLE wsc_option ADD CONSTRAINT FK_5E8C9692F8697D13 FOREIGN KEY (comment_id) REFERENCES ws_comment (id) ON DELETE CASCADE');
  43.         $this->addSql('CREATE INDEX IDX_5E8C9692F8697D13 ON wsc_option (comment_id)');
  44.     }
  45. }