migrations/Version20211208062845.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 Version20211208062845 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Drop demand tree table';
  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('ALTER TABLE demand DROP FOREIGN KEY FK_428D7973A8F18A7B');
  19.         $this->addSql('DROP TABLE demand_tree');
  20.         $this->addSql('DROP INDEX UNIQ_428D7973A8F18A7B ON demand');
  21.         $this->addSql('ALTER TABLE demand DROP demand_tree_id');
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         // this down() migration is auto-generated, please modify it to your needs
  26.         $this->addSql('CREATE TABLE demand_tree (id INT AUTO_INCREMENT NOT NULL, demand_id INT NOT NULL, tree_state INT DEFAULT NULL, tree_height INT DEFAULT NULL, height_approximation VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, tree_diameter INT DEFAULT NULL, diameter_approximation VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, tree_location LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:json)\', overgrown_lianas TINYINT(1) DEFAULT NULL, tree_accessibility TINYINT(1) DEFAULT NULL, waste_evacuation TINYINT(1) DEFAULT NULL, tree_damaged LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_69FCFE9A5D022E59 (demand_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
  27.         $this->addSql('ALTER TABLE demand_tree ADD CONSTRAINT FK_69FCFE9A5D022E59 FOREIGN KEY (demand_id) REFERENCES demand (id)');
  28.         $this->addSql('ALTER TABLE demand ADD demand_tree_id INT DEFAULT NULL');
  29.         $this->addSql('ALTER TABLE demand ADD CONSTRAINT FK_428D7973A8F18A7B FOREIGN KEY (demand_tree_id) REFERENCES demand_tree (id)');
  30.         $this->addSql('CREATE UNIQUE INDEX UNIQ_428D7973A8F18A7B ON demand (demand_tree_id)');
  31.     }
  32. }