<?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 Version20190923160721 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->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$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');
$this->addSql('ALTER TABLE feed_option ADD CONSTRAINT FK_98A4704451A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE feed ADD hide_results TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE feed_participant ADD option_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE feed_participant ADD CONSTRAINT FK_C3111A52A7C41D6F FOREIGN KEY (option_id) REFERENCES feed_option (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_C3111A52A7C41D6F ON feed_participant (option_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE feed_participant DROP FOREIGN KEY FK_C3111A52A7C41D6F');
$this->addSql('DROP TABLE feed_option');
$this->addSql('ALTER TABLE feed DROP hide_results');
$this->addSql('DROP INDEX IDX_C3111A52A7C41D6F ON feed_participant');
$this->addSql('ALTER TABLE feed_participant DROP option_id');
}
}