migrations/Version20221020122411.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 Version20221020122411 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 answer (id INT AUTO_INCREMENT NOT NULL, question_id INT NOT NULL, text VARCHAR(255) NOT NULL, score INT NOT NULL, sort_order INT NOT NULL, status TINYINT(1) NOT NULL, date_added DATETIME NOT NULL, date_modified DATETIME NOT NULL, INDEX IDX_DADD4A251E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE participant_answer (id INT AUTO_INCREMENT NOT NULL, participant_id INT UNSIGNED NOT NULL, question_id INT NOT NULL, answer_id INT NOT NULL, status TINYINT(1) NOT NULL, date_added DATETIME NOT NULL, date_modified DATETIME NOT NULL, INDEX IDX_68A1F4A49D1C3019 (participant_id), INDEX IDX_68A1F4A41E27F6BF (question_id), INDEX IDX_68A1F4A4AA334807 (answer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE question (id INT AUTO_INCREMENT NOT NULL, text VARCHAR(400) NOT NULL, short_name VARCHAR(25) NOT NULL, type VARCHAR(255) NOT NULL, status TINYINT(1) NOT NULL, sort_order INT NOT NULL, date_added DATETIME NOT NULL, date_modified DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A251E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
  22.         $this->addSql('ALTER TABLE participant_answer ADD CONSTRAINT FK_68A1F4A49D1C3019 FOREIGN KEY (participant_id) REFERENCES participant (id)');
  23.         $this->addSql('ALTER TABLE participant_answer ADD CONSTRAINT FK_68A1F4A41E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
  24.         $this->addSql('ALTER TABLE participant_answer ADD CONSTRAINT FK_68A1F4A4AA334807 FOREIGN KEY (answer_id) REFERENCES answer (id)');
  25.         $this->addSql('ALTER TABLE participant ADD vat_id VARCHAR(255) NOT NULL, ADD score INT DEFAULT 0');
  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 participant_answer DROP FOREIGN KEY FK_68A1F4A4AA334807');
  31.         $this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
  32.         $this->addSql('ALTER TABLE participant_answer DROP FOREIGN KEY FK_68A1F4A41E27F6BF');
  33.         $this->addSql('DROP TABLE answer');
  34.         $this->addSql('DROP TABLE participant_answer');
  35.         $this->addSql('DROP TABLE question');
  36.         $this->addSql('ALTER TABLE participant DROP vat_id, DROP score');
  37.     }
  38. }