migrations/Version20221011130436.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 Version20221011130436 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 poll (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE poll_answer (id INT AUTO_INCREMENT NOT NULL, poll_id INT NOT NULL, content LONGTEXT NOT NULL, INDEX IDX_36D8097E3C947C0F (poll_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE poll_result (id INT AUTO_INCREMENT NOT NULL, poll_answer_id INT NOT NULL, INDEX IDX_FF6F824861E461F3 (poll_answer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE poll_answer ADD CONSTRAINT FK_36D8097E3C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
  22.         $this->addSql('ALTER TABLE poll_result ADD CONSTRAINT FK_FF6F824861E461F3 FOREIGN KEY (poll_answer_id) REFERENCES poll_answer (id)');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE poll_answer DROP FOREIGN KEY FK_36D8097E3C947C0F');
  28.         $this->addSql('ALTER TABLE poll_result DROP FOREIGN KEY FK_FF6F824861E461F3');
  29.         $this->addSql('DROP TABLE poll');
  30.         $this->addSql('DROP TABLE poll_answer');
  31.         $this->addSql('DROP TABLE poll_result');
  32.     }
  33. }