<?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 Version20220310150720 extends AbstractMigration
{
public function getDescription(): string
{
return 'Store ids for Content Block and Content Block PDPs';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE store_content_blocks_store (content_block_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', store_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_15298D6BB5A68E3 (content_block_id), INDEX IDX_15298D6B092A811 (store_id), PRIMARY KEY(content_block_id, store_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE store_content_blocks_pdp_store (content_block_pdp_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', store_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_29C47F27694B9B65 (content_block_pdp_id), INDEX IDX_29C47F27B092A811 (store_id), PRIMARY KEY(content_block_pdp_id, store_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE store_content_blocks_store ADD CONSTRAINT FK_15298D6BB5A68E3 FOREIGN KEY (content_block_id) REFERENCES store_content_blocks (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_content_blocks_store ADD CONSTRAINT FK_15298D6B092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_content_blocks_pdp_store ADD CONSTRAINT FK_29C47F27694B9B65 FOREIGN KEY (content_block_pdp_id) REFERENCES store_content_blocks_pdp (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_content_blocks_pdp_store ADD CONSTRAINT FK_29C47F27B092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_content_blocks DROP FOREIGN KEY FK_B14DF80AB092A811');
$this->addSql('DROP INDEX IDX_B14DF80AB092A811 ON store_content_blocks');
$this->addSql('DROP INDEX store_identifier ON store_content_blocks');
$this->addSql('ALTER TABLE store_content_blocks DROP store_id, CHANGE active stores_excluded TINYINT(1) NOT NULL AFTER drupal_id');
$this->addSql('CREATE INDEX IDX_IDENTIFIER ON store_content_blocks (identifier)');
$this->addSql('ALTER TABLE store_content_blocks_pdp DROP FOREIGN KEY FK_9A940779B092A811');
$this->addSql('DROP INDEX IDX_9A940779B092A811 ON store_content_blocks_pdp');
$this->addSql('DROP INDEX store_category_slug ON store_content_blocks_pdp');
$this->addSql('ALTER TABLE store_content_blocks_pdp ADD stores_excluded TINYINT(1) NOT NULL AFTER drupal_id, DROP store_id');
$this->addSql('CREATE INDEX IDX_CATEGORY_SLUG ON store_content_blocks_pdp (category_slug)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE store_content_blocks_store');
$this->addSql('DROP TABLE store_content_blocks_pdp_store');
$this->addSql('DROP INDEX IDX_IDENTIFIER ON store_content_blocks');
$this->addSql('ALTER TABLE store_content_blocks ADD store_id CHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:uuid)\', CHANGE stores_excluded active TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE store_content_blocks ADD CONSTRAINT FK_B14DF80AB092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_B14DF80AB092A811 ON store_content_blocks (store_id)');
$this->addSql('CREATE UNIQUE INDEX store_identifier ON store_content_blocks (store_id, identifier)');
$this->addSql('DROP INDEX IDX_CATEGORY_SLUG ON store_content_blocks_pdp');
$this->addSql('ALTER TABLE store_content_blocks_pdp ADD store_id CHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:uuid)\', DROP stores_excluded');
$this->addSql('ALTER TABLE store_content_blocks_pdp ADD CONSTRAINT FK_9A940779B092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_9A940779B092A811 ON store_content_blocks_pdp (store_id)');
$this->addSql('CREATE UNIQUE INDEX store_category_slug ON store_content_blocks_pdp (store_id, category_slug)');
}
public function isTransactional(): bool
{
return false;
}
}