<?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 Version20220203072748 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 order_product (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, product_variant_id INT DEFAULT NULL, order_id INT NOT NULL, quantity INT DEFAULT NULL, price DOUBLE PRECISION DEFAULT NULL, total_price DOUBLE PRECISION DEFAULT NULL, INDEX IDX_2530ADE64584665A (product_id), INDEX IDX_2530ADE6A80EF684 (product_variant_id), INDEX IDX_2530ADE68D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE order_product ADD CONSTRAINT FK_2530ADE64584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE order_product ADD CONSTRAINT FK_2530ADE6A80EF684 FOREIGN KEY (product_variant_id) REFERENCES product_variant (id)');
$this->addSql('ALTER TABLE order_product ADD CONSTRAINT FK_2530ADE68D9F6D38 FOREIGN KEY (order_id) REFERENCES orders (id)');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE4584665A');
$this->addSql('DROP INDEX IDX_E52FFDEE4584665A ON orders');
$this->addSql('ALTER TABLE orders DROP product_id, DROP product_name, DROP product_variant_name, DROP count, DROP discount');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE order_product');
$this->addSql('ALTER TABLE orders ADD product_id INT DEFAULT NULL, ADD product_name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD product_variant_name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD count INT NOT NULL, ADD discount INT DEFAULT NULL');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE4584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('CREATE INDEX IDX_E52FFDEE4584665A ON orders (product_id)');
}
}