<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20211208062845 extends AbstractMigration
{
public function getDescription(): string
{
return 'Drop demand tree table';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE demand DROP FOREIGN KEY FK_428D7973A8F18A7B');
$this->addSql('DROP TABLE demand_tree');
$this->addSql('DROP INDEX UNIQ_428D7973A8F18A7B ON demand');
$this->addSql('ALTER TABLE demand DROP demand_tree_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$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 = \'\' ');
$this->addSql('ALTER TABLE demand_tree ADD CONSTRAINT FK_69FCFE9A5D022E59 FOREIGN KEY (demand_id) REFERENCES demand (id)');
$this->addSql('ALTER TABLE demand ADD demand_tree_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE demand ADD CONSTRAINT FK_428D7973A8F18A7B FOREIGN KEY (demand_tree_id) REFERENCES demand_tree (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_428D7973A8F18A7B ON demand (demand_tree_id)');
}
}