migrations/Version20190923160721.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 Version20190923160721 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->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE feed_option (id INT AUTO_INCREMENT NOT NULL, feed_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_98A4704451A5BC03 (feed_id), INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE feed_option ADD CONSTRAINT FK_98A4704451A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id) ON DELETE CASCADE');
  21.         $this->addSql('ALTER TABLE feed ADD hide_results TINYINT(1) NOT NULL');
  22.         $this->addSql('ALTER TABLE feed_participant ADD option_id INT DEFAULT NULL');
  23.         $this->addSql('ALTER TABLE feed_participant ADD CONSTRAINT FK_C3111A52A7C41D6F FOREIGN KEY (option_id) REFERENCES feed_option (id) ON DELETE SET NULL');
  24.         $this->addSql('CREATE INDEX IDX_C3111A52A7C41D6F ON feed_participant (option_id)');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  30.         $this->addSql('ALTER TABLE feed_participant DROP FOREIGN KEY FK_C3111A52A7C41D6F');
  31.         $this->addSql('DROP TABLE feed_option');
  32.         $this->addSql('ALTER TABLE feed DROP hide_results');
  33.         $this->addSql('DROP INDEX IDX_C3111A52A7C41D6F ON feed_participant');
  34.         $this->addSql('ALTER TABLE feed_participant DROP option_id');
  35.     }
  36. }