migrations/Version20211023180232.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 Version20211023180232 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->addSql('CREATE TABLE vehicle_route (id INT AUTO_INCREMENT NOT NULL, vehicle_id INT DEFAULT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, date DATETIME NOT NULL, estimated_start TIME NOT NULL, estimated_end TIME NOT NULL, duration INT NOT NULL, distance INT NOT NULL, encoded_polyline LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_606BA095545317D1 (vehicle_id), INDEX IDX_606BA095B03A8386 (created_by_id), INDEX IDX_606BA095896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
  20.         $this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
  21.         $this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)');
  22.         $this->addSql('ALTER TABLE order_shipping DROP FOREIGN KEY FK_CCE4F595545317D1');
  23.         $this->addSql('DROP INDEX IDX_CCE4F595545317D1 ON order_shipping');
  24.         $this->addSql('ALTER TABLE order_shipping CHANGE date date DATETIME NOT NULL, ADD route_id INT DEFAULT NULL');
  25.         $this->addSql('ALTER TABLE order_shipping ADD CONSTRAINT FK_CCE4F59534ECB4E6 FOREIGN KEY (route_id) REFERENCES vehicle_route (id)');
  26.         $this->addSql('CREATE INDEX IDX_CCE4F59534ECB4E6 ON order_shipping (route_id)');
  27.         $this->addSql('ALTER TABLE order_shipping DROP vehicle_id, ADD estimated_delivery_time TIME DEFAULT NULL');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         // this down() migration is auto-generated, please modify it to your needs
  32.         $this->addSql('ALTER TABLE order_shipping DROP FOREIGN KEY FK_CCE4F59534ECB4E6');
  33.         $this->addSql('DROP TABLE vehicle_route');
  34.         $this->addSql('DROP INDEX IDX_CCE4F59534ECB4E6 ON order_shipping');
  35.         $this->addSql('ALTER TABLE order_shipping CHANGE date date DATETIME DEFAULT NULL, ADD vehicle_id INT DEFAULT NULL');
  36.         $this->addSql('ALTER TABLE order_shipping DROP route_id, DROP estimated_delivery_time');
  37.         $this->addSql('ALTER TABLE order_shipping ADD CONSTRAINT FK_CCE4F595545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
  38.         $this->addSql('CREATE INDEX IDX_CCE4F595545317D1 ON order_shipping (vehicle_id)');
  39.         
  40.     }
  41.     
  42.     public function isTransactional(): bool
  43.     {
  44.         return false;
  45.     }
  46. }