<?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 Version20200728133205 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 invoice ADD billing_address_id INT DEFAULT NULL, DROP observation');
$this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_9065174479D0C0E4 FOREIGN KEY (billing_address_id) REFERENCES billing_address (id)');
$this->addSql('CREATE INDEX IDX_9065174479D0C0E4 ON invoice (billing_address_id)');
$this->addSql('UPDATE invoice LEFT JOIN orders ON orders.id=invoice.order_id SET invoice.billing_address_id=orders.billing_address_id');
}
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('ALTER TABLE invoice DROP FOREIGN KEY FK_9065174479D0C0E4');
$this->addSql('DROP INDEX IDX_9065174479D0C0E4 ON invoice');
$this->addSql('ALTER TABLE invoice ADD observation VARCHAR(500) CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_unicode_ci`, DROP billing_address_id');
}
}