migrations/Version20201015023912.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 Version20201015023912 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         //$this->addSql(file_get_contents(__DIR__ . '/../../zones.sql'));
  18.         // this up() migration is auto-generated, please modify it to your needs
  19.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  20.         $this->addSql('DROP TABLE order_renegotiation');
  21.         $this->addSql('ALTER TABLE orders ADD delivery_start_time TIME NULL, ADD delivery_end_time TIME NULL');
  22.         $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');
  23.         $this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE98166393');
  24.         $this->addSql('DROP INDEX IDX_E52FFDEE98166393 ON orders');
  25.         $this->addSql('ALTER TABLE orders DROP delivery_schedule_id');
  26.     }
  27.     public function down(Schema $schema) : void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  31.         $this->addSql('ALTER TABLE orders ADD delivery_schedule_id INT DEFAULT NULL');
  32.         $this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE98166393 FOREIGN KEY (delivery_schedule_id) REFERENCES delivery_schedule (id)');
  33.         $this->addSql('CREATE INDEX IDX_E52FFDEE98166393 ON orders (delivery_schedule_id)');
  34.         
  35.         $this->addSql('ALTER TABLE orders DROP delivery_start_time, DROP delivery_end_time');
  36.         $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 = \'\' ');
  37.         $this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F398166393 FOREIGN KEY (delivery_schedule_id) REFERENCES delivery_schedule (id)');
  38.         $this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F3D3564642 FOREIGN KEY (createdBy) REFERENCES users (id)');
  39.         $this->addSql('ALTER TABLE order_renegotiation ADD CONSTRAINT FK_B451F8F3E2EDD085 FOREIGN KEY (idOrder) REFERENCES orders (id)');
  40.     }
  41. }