<?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 Version20211023180232 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->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');
$this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
$this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE vehicle_route ADD CONSTRAINT FK_606BA095896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE order_shipping DROP FOREIGN KEY FK_CCE4F595545317D1');
$this->addSql('DROP INDEX IDX_CCE4F595545317D1 ON order_shipping');
$this->addSql('ALTER TABLE order_shipping CHANGE date date DATETIME NOT NULL, ADD route_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE order_shipping ADD CONSTRAINT FK_CCE4F59534ECB4E6 FOREIGN KEY (route_id) REFERENCES vehicle_route (id)');
$this->addSql('CREATE INDEX IDX_CCE4F59534ECB4E6 ON order_shipping (route_id)');
$this->addSql('ALTER TABLE order_shipping DROP vehicle_id, ADD estimated_delivery_time TIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE order_shipping DROP FOREIGN KEY FK_CCE4F59534ECB4E6');
$this->addSql('DROP TABLE vehicle_route');
$this->addSql('DROP INDEX IDX_CCE4F59534ECB4E6 ON order_shipping');
$this->addSql('ALTER TABLE order_shipping CHANGE date date DATETIME DEFAULT NULL, ADD vehicle_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE order_shipping DROP route_id, DROP estimated_delivery_time');
$this->addSql('ALTER TABLE order_shipping ADD CONSTRAINT FK_CCE4F595545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
$this->addSql('CREATE INDEX IDX_CCE4F595545317D1 ON order_shipping (vehicle_id)');
}
public function isTransactional(): bool
{
return false;
}
}