<?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 Version20220310124902 extends AbstractMigration
{
public function getDescription(): string
{
return 'Page store ids';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE store_page_store (page_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', store_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_B73FFC4CC4663E4 (page_id), INDEX IDX_B73FFC4CB092A811 (store_id), PRIMARY KEY(page_id, store_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE store_page_store ADD CONSTRAINT FK_B73FFC4CC4663E4 FOREIGN KEY (page_id) REFERENCES store_page (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_page_store ADD CONSTRAINT FK_B73FFC4CB092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE store_page DROP FOREIGN KEY FK_F6B318EEB092A811');
$this->addSql('DROP INDEX IDX_F6B318EEB092A811 ON store_page');
$this->addSql('DROP INDEX store_identifier ON store_page');
$this->addSql('ALTER TABLE store_page ADD stores_excluded TINYINT(1) NOT NULL, DROP store_id');
$this->addSql('CREATE INDEX IDX_IDENTIFIER ON store_page (identifier)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE store_page_store');
$this->addSql('DROP INDEX IDX_IDENTIFIER ON store_page');
$this->addSql('ALTER TABLE store_page 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_page ADD CONSTRAINT FK_F6B318EEB092A811 FOREIGN KEY (store_id) REFERENCES store (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
$this->addSql('CREATE INDEX IDX_F6B318EEB092A811 ON store_page (store_id)');
$this->addSql('CREATE UNIQUE INDEX store_identifier ON store_page (store_id, identifier)');
}
public function isTransactional(): bool
{
return false;
}
}