<?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 Version20200125011650 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 cartItems DROP FOREIGN KEY FK_921FB66B785ED629');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE785ED629');
$this->addSql('CREATE TABLE cart (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, shipping_address_id INT DEFAULT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, session VARCHAR(100) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_BA388B79395C3F3 (customer_id), INDEX IDX_BA388B74D4CFF2B (shipping_address_id), INDEX IDX_BA388B7B03A8386 (created_by_id), INDEX IDX_BA388B7896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE cart ADD CONSTRAINT FK_BA388B79395C3F3 FOREIGN KEY (customer_id) REFERENCES clients (id)');
$this->addSql('ALTER TABLE cart ADD CONSTRAINT FK_BA388B74D4CFF2B FOREIGN KEY (shipping_address_id) REFERENCES street_address (id)');
$this->addSql('ALTER TABLE cart ADD CONSTRAINT FK_BA388B7B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE cart ADD CONSTRAINT FK_BA388B7896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)');
$this->addSql('DROP TABLE carts');
$this->addSql('DROP INDEX IDX_E52FFDEE785ED629 ON orders');
$this->addSql('ALTER TABLE orders DROP idCart');
}
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('CREATE TABLE carts (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, shipping_address_id INT DEFAULT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, subtotal NUMERIC(10, 2) NOT NULL, tax NUMERIC(10, 2) NOT NULL, total NUMERIC(10, 2) NOT NULL, source VARCHAR(20) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, session VARCHAR(100) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, active TINYINT(1) DEFAULT \'1\' NOT NULL, updatedBy INT DEFAULT NULL, INDEX IDX_4E004AAC9395C3F3 (customer_id), INDEX IDX_4E004AACE8DE7170 (updatedBy), INDEX IDX_4E004AAC4D4CFF2B (shipping_address_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE carts ADD CONSTRAINT FK_4E004AAC4D4CFF2B FOREIGN KEY (shipping_address_id) REFERENCES street_address (id)');
$this->addSql('ALTER TABLE carts ADD CONSTRAINT FK_4E004AAC9395C3F3 FOREIGN KEY (customer_id) REFERENCES clients (id)');
$this->addSql('ALTER TABLE carts ADD CONSTRAINT FK_4E004AACE8DE7170 FOREIGN KEY (updatedBy) REFERENCES users (id)');
$this->addSql('DROP TABLE cart');
$this->addSql('ALTER TABLE cartItems ADD CONSTRAINT FK_921FB66B785ED629 FOREIGN KEY (idCart) REFERENCES carts (id)');
$this->addSql('ALTER TABLE orders ADD idCart INT DEFAULT NULL');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE785ED629 FOREIGN KEY (idCart) REFERENCES carts (id)');
$this->addSql('CREATE INDEX IDX_E52FFDEE785ED629 ON orders (idCart)');
}
}