migrations/Version20220526115751.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 Version20220526115751 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('CREATE TABLE voting_anonymous_passing (id INT AUTO_INCREMENT NOT NULL, voting_id INT NOT NULL, fingerprint VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_F835CC9B4254ACF8 (voting_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE voting_anonymous_passing ADD CONSTRAINT FK_F835CC9B4254ACF8 FOREIGN KEY (voting_id) REFERENCES voting (id) ON DELETE CASCADE');
  20.         $this->addSql('ALTER TABLE custom_user_answer ADD anonymous_passing_id INT DEFAULT NULL');
  21.         $this->addSql('ALTER TABLE custom_user_answer ADD CONSTRAINT FK_89B3E4D2941913C6 FOREIGN KEY (anonymous_passing_id) REFERENCES voting_anonymous_passing (id) ON DELETE CASCADE');
  22.         $this->addSql('CREATE INDEX IDX_89B3E4D2941913C6 ON custom_user_answer (anonymous_passing_id)');
  23.         $this->addSql('ALTER TABLE user_answer ADD anonymous_passing_id INT DEFAULT NULL');
  24.         $this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F5118941913C6 FOREIGN KEY (anonymous_passing_id) REFERENCES voting_anonymous_passing (id) ON DELETE CASCADE');
  25.         $this->addSql('CREATE INDEX IDX_BF8F5118941913C6 ON user_answer (anonymous_passing_id)');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE custom_user_answer DROP FOREIGN KEY FK_89B3E4D2941913C6');
  31.         $this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F5118941913C6');
  32.         $this->addSql('DROP TABLE voting_anonymous_passing');
  33.         $this->addSql('DROP INDEX IDX_89B3E4D2941913C6 ON custom_user_answer');
  34.         $this->addSql('ALTER TABLE custom_user_answer DROP anonymous_passing_id');
  35.         $this->addSql('DROP INDEX IDX_BF8F5118941913C6 ON user_answer');
  36.         $this->addSql('ALTER TABLE user_answer DROP anonymous_passing_id');
  37.     }
  38. }