migrations/Version20190804200747.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 Version20190804200747 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('ALTER TABLE delivery_schedule DROP FOREIGN KEY FK_3B59F097A40BC2D5');
  20.         $this->addSql('DROP INDEX IDX_3B59F097A40BC2D5 ON delivery_schedule');
  21.         $this->addSql('ALTER TABLE delivery_schedule ADD start TIME NOT NULL, ADD end TIME NOT NULL');
  22.         // migrate data
  23.         $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');
  24.         // remove schedule_id
  25.         $this->addSql('ALTER TABLE delivery_schedule DROP schedule_id');
  26.         // drop schedules table
  27.         $this->addSql('DROP TABLE schedules');
  28.         // drop schedule range from orders
  29.         $this->addSql('ALTER TABLE orders DROP scheduleRange');
  30.     }
  31.     public function down(Schema $schema) : void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  35. //        $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 = \'\' ');
  36. //        $this->addSql('ALTER TABLE delivery_schedule DROP start, DROP end');
  37. //        $this->addSql('ALTER TABLE delivery_schedule ADD CONSTRAINT FK_3B59F097A40BC2D5 FOREIGN KEY (schedule_id) REFERENCES schedules (id)');
  38. //        $this->addSql('CREATE INDEX IDX_3B59F097A40BC2D5 ON delivery_schedule (schedule_id)');
  39.     }
  40. }