<?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 Version20200125010423 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 carts ADD customer_id INT DEFAULT NULL, ADD shipping_address_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE carts ADD CONSTRAINT FK_4E004AAC9395C3F3 FOREIGN KEY (customer_id) REFERENCES clients (id)');
$this->addSql('ALTER TABLE carts ADD CONSTRAINT FK_4E004AAC4D4CFF2B FOREIGN KEY (shipping_address_id) REFERENCES street_address (id)');
$this->addSql('CREATE INDEX IDX_4E004AAC9395C3F3 ON carts (customer_id)');
$this->addSql('CREATE INDEX IDX_4E004AAC4D4CFF2B ON carts (shipping_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 carts DROP FOREIGN KEY FK_4E004AAC9395C3F3');
$this->addSql('ALTER TABLE carts DROP FOREIGN KEY FK_4E004AAC4D4CFF2B');
$this->addSql('DROP INDEX IDX_4E004AAC9395C3F3 ON carts');
$this->addSql('DROP INDEX IDX_4E004AAC4D4CFF2B ON carts');
$this->addSql('ALTER TABLE carts DROP customer_id, DROP shipping_address_id');
}
}