<?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 Version20210702145129 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('ALTER TABLE order_shipping ADD shipping_address_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE order_shipping ADD CONSTRAINT FK_CCE4F5954D4CFF2B FOREIGN KEY (shipping_address_id) REFERENCES street_address (id)');
$this->addSql('UPDATE order_shipping LEFT JOIN orders ON orders.id=order_shipping.order_id SET order_shipping.shipping_address_id=orders.shipping_address_id');
$this->addSql('CREATE INDEX IDX_CCE4F5954D4CFF2B ON order_shipping (shipping_address_id)');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEEEBF23851');
$this->addSql('DROP INDEX IDX_E52FFDEE4D4CFF2B ON orders');
$this->addSql('ALTER TABLE orders DROP shipping_address_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX IDX_CCE4F5954D4CFF2B ON order_shipping');
$this->addSql('ALTER TABLE order_shipping DROP shipping_address_id');
$this->addSql('ALTER TABLE orders ADD shipping_address_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEEEBF23851 FOREIGN KEY (shipping_address_id) REFERENCES street_address (id)');
$this->addSql('CREATE INDEX IDX_E52FFDEE4D4CFF2B ON orders (shipping_address_id)');
}
public function isTransactional(): bool
{
return false;
}
}