migrations/Version20220615115421.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 Version20220615115421 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 question (id INT AUTO_INCREMENT NOT NULL, titre VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE docteur ADD question_id INT DEFAULT NULL');
  20.         $this->addSql('ALTER TABLE docteur ADD CONSTRAINT FK_83A7A4391E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
  21.         $this->addSql('CREATE INDEX IDX_83A7A4391E27F6BF ON docteur (question_id)');
  22.         $this->addSql('ALTER TABLE patient ADD question_id INT DEFAULT NULL');
  23.         $this->addSql('ALTER TABLE patient ADD CONSTRAINT FK_1ADAD7EB1E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
  24.         $this->addSql('CREATE INDEX IDX_1ADAD7EB1E27F6BF ON patient (question_id)');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('ALTER TABLE docteur DROP FOREIGN KEY FK_83A7A4391E27F6BF');
  30.         $this->addSql('ALTER TABLE patient DROP FOREIGN KEY FK_1ADAD7EB1E27F6BF');
  31.         $this->addSql('DROP TABLE question');
  32.         $this->addSql('DROP INDEX IDX_83A7A4391E27F6BF ON docteur');
  33.         $this->addSql('ALTER TABLE docteur DROP question_id');
  34.         $this->addSql('DROP INDEX IDX_1ADAD7EB1E27F6BF ON patient');
  35.         $this->addSql('ALTER TABLE patient DROP question_id');
  36.     }
  37. }