<?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 Version20201015023912 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
//$this->addSql(file_get_contents(__DIR__ . '/../../zones.sql'));
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('DROP TABLE order_renegotiation');
$this->addSql('ALTER TABLE orders ADD delivery_start_time TIME NULL, ADD delivery_end_time TIME NULL');
$this->addSql('UPDATE orders LEFT JOIN delivery_schedule ON delivery_schedule.id=orders.delivery_schedule_id SET orders.delivery_start_time=delivery_schedule.start, orders.delivery_end_time=delivery_schedule.end');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE98166393');
$this->addSql('DROP INDEX IDX_E52FFDEE98166393 ON orders');
$this->addSql('ALTER TABLE orders DROP delivery_schedule_id');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE orders ADD delivery_schedule_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE98166393 FOREIGN KEY (delivery_schedule_id) REFERENCES delivery_schedule (id)');
$this->addSql('CREATE INDEX IDX_E52FFDEE98166393 ON orders (delivery_schedule_id)');
$this->addSql('ALTER TABLE orders DROP delivery_start_time, DROP delivery_end_time');
$this->addSql('CREATE TABLE order_renegotiation (id INT AUTO_INCREMENT NOT NULL, delivery_schedule_id INT DEFAULT NULL, createdAt DATETIME NOT NULL, source VARCHAR(20) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, deliveryDate DATETIME NOT NULL, createdBy INT DEFAULT NULL, idOrder INT DEFAULT NULL, INDEX IDX_B451F8F398166393 (delivery_schedule_id), INDEX IDX_B451F8F3D3564642 (createdBy), INDEX IDX_B451F8F3E2EDD085 (idOrder), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F398166393 FOREIGN KEY (delivery_schedule_id) REFERENCES delivery_schedule (id)');
$this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F3D3564642 FOREIGN KEY (createdBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F3E2EDD085 FOREIGN KEY (idOrder) REFERENCES orders (id)');
}
}