<?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 Version20190804200747 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// 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('ALTER TABLE delivery_schedule DROP FOREIGN KEY FK_3B59F097A40BC2D5');
$this->addSql('DROP INDEX IDX_3B59F097A40BC2D5 ON delivery_schedule');
$this->addSql('ALTER TABLE delivery_schedule ADD start TIME NOT NULL, ADD end TIME NOT NULL');
// migrate data
$this->addSql('UPDATE delivery_schedule JOIN schedules ON schedules.id = delivery_schedule.schedule_id SET delivery_schedule.start=schedules.start, delivery_schedule.end=schedules.end');
// remove schedule_id
$this->addSql('ALTER TABLE delivery_schedule DROP schedule_id');
// drop schedules table
$this->addSql('DROP TABLE schedules');
// drop schedule range from orders
$this->addSql('ALTER TABLE orders DROP scheduleRange');
}
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('CREATE TABLE schedules (id INT AUTO_INCREMENT NOT NULL, start TIME NOT NULL, end TIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
// $this->addSql('ALTER TABLE delivery_schedule DROP start, DROP end');
// $this->addSql('ALTER TABLE delivery_schedule ADD CONSTRAINT FK_3B59F097A40BC2D5 FOREIGN KEY (schedule_id) REFERENCES schedules (id)');
// $this->addSql('CREATE INDEX IDX_3B59F097A40BC2D5 ON delivery_schedule (schedule_id)');
}
}