migrations/Version20231117165423.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 Version20231117165423 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Survey';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('CREATE TABLE answer (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, question_id BIGINT UNSIGNED DEFAULT NULL, answer_text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_DADD4A251E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  18.         $this->addSql('CREATE TABLE answer_sub_questions (answer_id BIGINT UNSIGNED NOT NULL, question_id BIGINT UNSIGNED NOT NULL, INDEX IDX_D6773740AA334807 (answer_id), INDEX IDX_D67737401E27F6BF (question_id), PRIMARY KEY(answer_id, question_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE question (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, parent_question_id BIGINT UNSIGNED DEFAULT NULL, question_text LONGTEXT NOT NULL, question_type VARCHAR(255) NOT NULL, tech_name VARCHAR(255) DEFAULT NULL, position BIGINT UNSIGNED NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_B6F7494E48900AE7 (tech_name), INDEX IDX_B6F7494E750BE4CF (parent_question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE user_answer (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, creator_id BIGINT UNSIGNED DEFAULT NULL, question_id BIGINT UNSIGNED DEFAULT NULL, answer_id BIGINT UNSIGNED DEFAULT NULL, answer_text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_BF8F511861220EA6 (creator_id), INDEX IDX_BF8F51181E27F6BF (question_id), INDEX IDX_BF8F5118AA334807 (answer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_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 answer_sub_questions ADD CONSTRAINT FK_D6773740AA334807 FOREIGN KEY (answer_id) REFERENCES answer (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE answer_sub_questions ADD CONSTRAINT FK_D67737401E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE question ADD CONSTRAINT FK_B6F7494E750BE4CF FOREIGN KEY (parent_question_id) REFERENCES question (id)');
  25.         $this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F511861220EA6 FOREIGN KEY (creator_id) REFERENCES creator (id)');
  26.         $this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F51181E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
  27.         $this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F5118AA334807 FOREIGN KEY (answer_id) REFERENCES answer (id)');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         $this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
  32.         $this->addSql('ALTER TABLE answer_sub_questions DROP FOREIGN KEY FK_D6773740AA334807');
  33.         $this->addSql('ALTER TABLE answer_sub_questions DROP FOREIGN KEY FK_D67737401E27F6BF');
  34.         $this->addSql('ALTER TABLE question DROP FOREIGN KEY FK_B6F7494E750BE4CF');
  35.         $this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F511861220EA6');
  36.         $this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F51181E27F6BF');
  37.         $this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F5118AA334807');
  38.         $this->addSql('DROP TABLE answer');
  39.         $this->addSql('DROP TABLE answer_sub_questions');
  40.         $this->addSql('DROP TABLE question');
  41.         $this->addSql('DROP TABLE user_answer');
  42.     }
  43. }