<?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 Version20220212094257 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 brands__aliases (id INT AUTO_INCREMENT NOT NULL, brand_id INT NOT NULL, value VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3A8CEC1B1D775834 (value), INDEX IDX_3A8CEC1B44F5D008 (brand_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE brands__brands (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, legal_name VARCHAR(255) DEFAULT NULL, car_manufacturer TINYINT(1) DEFAULT \'0\' NOT NULL, slug VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_502CA06C5E237E06 (name), UNIQUE INDEX UNIQ_502CA06C735890B1 (legal_name), UNIQUE INDEX UNIQ_502CA06C989D9B62 (slug), INDEX name_idx (name), INDEX legal_name_idx (legal_name), INDEX car_manufacturer_idx (car_manufacturer), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE products__analogs (id INT AUTO_INCREMENT NOT NULL, owner_product_id INT NOT NULL, analog_product_id INT NOT NULL, enabled TINYINT(1) DEFAULT \'1\' NOT NULL, INDEX IDX_9683407617EEFF1F (owner_product_id), INDEX IDX_9683407641833BF1 (analog_product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE products__images (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, hash VARCHAR(255) NOT NULL, published TINYINT(1) DEFAULT \'1\' NOT NULL, INDEX IDX_C211A3B44584665A (product_id), UNIQUE INDEX unique_product_imghash (hash, product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE products__items (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, stock INT NOT NULL, price INT NOT NULL, show_in_search TINYINT(1) DEFAULT \'1\' NOT NULL, updated DATETIME DEFAULT NULL, INDEX IDX_ED158EFB4584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE products__products (id INT AUTO_INCREMENT NOT NULL, brand_id INT NOT NULL, article_search VARCHAR(255) NOT NULL, article_original VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, INDEX IDX_CF07FC1C44F5D008 (brand_id), UNIQUE INDEX unique_product (article_search, brand_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE brands__aliases ADD CONSTRAINT FK_3A8CEC1B44F5D008 FOREIGN KEY (brand_id) REFERENCES brands__brands (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products__analogs ADD CONSTRAINT FK_9683407617EEFF1F FOREIGN KEY (owner_product_id) REFERENCES products__products (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products__analogs ADD CONSTRAINT FK_9683407641833BF1 FOREIGN KEY (analog_product_id) REFERENCES products__products (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products__images ADD CONSTRAINT FK_C211A3B44584665A FOREIGN KEY (product_id) REFERENCES products__products (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products__items ADD CONSTRAINT FK_ED158EFB4584665A FOREIGN KEY (product_id) REFERENCES products__products (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE products__products ADD CONSTRAINT FK_CF07FC1C44F5D008 FOREIGN KEY (brand_id) REFERENCES brands__brands (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE cars__chassis RENAME INDEX idx_aa72d6117975b7e7 TO IDX_3DC2C6B07975B7E7');
$this->addSql('ALTER TABLE cars__engines RENAME INDEX idx_17543d427975b7e7 TO IDX_80E42DE37975B7E7');
$this->addSql('ALTER TABLE cars__models RENAME INDEX idx_e0975b4f44f5d008 TO IDX_825E724444F5D008');
$this->addSql('ALTER TABLE cars__sets RENAME INDEX idx_666d7550e78c9c0a TO IDX_53E5664CE78C9C0A');
$this->addSql('ALTER TABLE cars__sets RENAME INDEX idx_666d755063ee729 TO IDX_53E5664C63EE729');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE brands__aliases DROP FOREIGN KEY FK_3A8CEC1B44F5D008');
$this->addSql('ALTER TABLE products__products DROP FOREIGN KEY FK_CF07FC1C44F5D008');
$this->addSql('ALTER TABLE products__analogs DROP FOREIGN KEY FK_9683407617EEFF1F');
$this->addSql('ALTER TABLE products__analogs DROP FOREIGN KEY FK_9683407641833BF1');
$this->addSql('ALTER TABLE products__images DROP FOREIGN KEY FK_C211A3B44584665A');
$this->addSql('ALTER TABLE products__items DROP FOREIGN KEY FK_ED158EFB4584665A');
$this->addSql('DROP TABLE brands__aliases');
$this->addSql('DROP TABLE brands__brands');
$this->addSql('DROP TABLE products__analogs');
$this->addSql('DROP TABLE products__images');
$this->addSql('DROP TABLE products__items');
$this->addSql('DROP TABLE products__products');
$this->addSql('ALTER TABLE cars__chassis RENAME INDEX idx_3dc2c6b07975b7e7 TO IDX_AA72D6117975B7E7');
$this->addSql('ALTER TABLE cars__engines RENAME INDEX idx_80e42de37975b7e7 TO IDX_17543D427975B7E7');
$this->addSql('ALTER TABLE cars__models RENAME INDEX idx_825e724444f5d008 TO IDX_E0975B4F44F5D008');
$this->addSql('ALTER TABLE cars__sets RENAME INDEX idx_53e5664c63ee729 TO IDX_666D755063EE729');
$this->addSql('ALTER TABLE cars__sets RENAME INDEX idx_53e5664ce78c9c0a TO IDX_666D7550E78C9C0A');
}
}