migrations/Version20180326145319.php line 1

Open in your IDE?
  1. <?php declare (strict_types 1);
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: Please modify to your needs!
  7.  */
  8. class Version20180326145319 extends AbstractMigration
  9. {
  10.     public function up(Schema $schema): void
  11.     {
  12.         // this up() migration is auto-generated, please modify it to your needs
  13.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  14.         $this->addSql('ALTER TABLE user_survey_answer DROP FOREIGN KEY FK_1C5D2F1957CA8F96');
  15.         $this->addSql('CREATE TABLE membership_survey (`id` INT AUTO_INCREMENT NOT NULL, `start_date` DATETIME DEFAULT NULL, `end_date` DATETIME DEFAULT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, `membership_id` INT NOT NULL, `survey_id` INT NOT NULL, INDEX IDX_D3E22A653E2CBC4F (`membership_id`), INDEX IDX_D3E22A65C964D0DE (`survey_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  16.         $this->addSql('CREATE TABLE membership_survey_answer (`id` INT AUTO_INCREMENT NOT NULL, `value` VARCHAR(5000) DEFAULT NULL, `membershipSurvey_id` INT NOT NULL, `surveyDetail_id` INT NOT NULL, INDEX IDX_3AA26A7C8448D857 (`membershipSurvey_id`), INDEX IDX_3AA26A7C32FD39D4 (`surveyDetail_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  17.         $this->addSql('ALTER TABLE membership_survey ADD CONSTRAINT FK_D3E22A653E2CBC4F FOREIGN KEY (`membership_id`) REFERENCES membership (`id`)');
  18.         $this->addSql('ALTER TABLE membership_survey ADD CONSTRAINT FK_D3E22A65C964D0DE FOREIGN KEY (`survey_id`) REFERENCES survey (`id`)');
  19.         $this->addSql('ALTER TABLE membership_survey_answer ADD CONSTRAINT FK_3AA26A7C8448D857 FOREIGN KEY (`membershipSurvey_id`) REFERENCES membership_survey (`id`)');
  20.         $this->addSql('ALTER TABLE membership_survey_answer ADD CONSTRAINT FK_3AA26A7C32FD39D4 FOREIGN KEY (`surveyDetail_id`) REFERENCES survey_detail (`id`)');
  21.         $this->addSql('DROP TABLE user_survey');
  22.         $this->addSql('DROP TABLE user_survey_answer');
  23.         $this->addSql('ALTER TABLE membership ADD `status` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:membership_status)\', DROP state');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  29.         $this->addSql('ALTER TABLE membership_survey_answer DROP FOREIGN KEY FK_3AA26A7C8448D857');
  30.         $this->addSql('CREATE TABLE user_survey (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, survey_id INT NOT NULL, start_date DATETIME DEFAULT NULL, end_date DATETIME DEFAULT NULL, creation_user VARCHAR(50) NOT NULL COLLATE utf8_unicode_ci, creation_date DATETIME NOT NULL, modified_user VARCHAR(50) DEFAULT NULL COLLATE utf8_unicode_ci, modified_date DATETIME DEFAULT NULL, INDEX IDX_C80D80C1C03ACDAE (user_id), INDEX IDX_C80D80C1C964D0DE (survey_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  31.         $this->addSql('CREATE TABLE user_survey_answer (id INT AUTO_INCREMENT NOT NULL, value VARCHAR(5000) DEFAULT NULL COLLATE utf8_unicode_ci, userSurvey_id INT NOT NULL, surveyDetail_id INT NOT NULL, INDEX IDX_1C5D2F1957CA8F96 (userSurvey_id), INDEX IDX_1C5D2F1932FD39D4 (surveyDetail_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  32.         $this->addSql('ALTER TABLE user_survey ADD CONSTRAINT FK_C80D80C1C03ACDAE FOREIGN KEY (user_id) REFERENCES user (id)');
  33.         $this->addSql('ALTER TABLE user_survey ADD CONSTRAINT FK_C80D80C1C964D0DE FOREIGN KEY (survey_id) REFERENCES survey (id)');
  34.         $this->addSql('ALTER TABLE user_survey_answer ADD CONSTRAINT FK_1C5D2F1932FD39D4 FOREIGN KEY (surveyDetail_id) REFERENCES survey_detail (id)');
  35.         $this->addSql('ALTER TABLE user_survey_answer ADD CONSTRAINT FK_1C5D2F1957CA8F96 FOREIGN KEY (userSurvey_id) REFERENCES user_survey (id)');
  36.         $this->addSql('DROP TABLE membership_survey');
  37.         $this->addSql('DROP TABLE membership_survey_answer');
  38.         $this->addSql('ALTER TABLE membership ADD state VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci COMMENT \'(DC2Type:membership_state)\', DROP `status`');
  39.     }
  40. }