Merge branch '1.11' into 1.12

* 1.11:
  [Migrations] Remove Scope model in migrations
  [Migrations] Remove unnecessary DB restrictions in migrations
  issue/12985-migration-in-corebundle
This commit is contained in:
Grzegorz Sadowski 2022-11-16 13:36:22 +01:00
commit 009bc95e21
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
2 changed files with 6 additions and 61 deletions

View file

@ -15,44 +15,16 @@ namespace Sylius\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Sylius\Bundle\CoreBundle\Doctrine\Migrations\AbstractMigration;
use Sylius\Component\Addressing\Model\Scope;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Version20161209095131 extends AbstractMigration implements ContainerAwareInterface
class Version20161209095131 extends AbstractMigration
{
/** @var ContainerInterface */
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function up(Schema $schema): void
{
$zoneRepository = $this->container->get('sylius.repository.zone');
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ZoneInterface $zone */
foreach ($zoneRepository->findBy(['scope' => null]) as $zone) {
$zone->setScope(Scope::ALL);
}
$entityManager->flush();
$this->addSql("UPDATE sylius_zone SET scope = 'all' WHERE scope IS NULL");
}
public function down(Schema $schema): void
{
$zoneRepository = $this->container->get('sylius.repository.zone');
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ZoneInterface $zone */
foreach ($zoneRepository->findBy(['scope' => Scope::ALL]) as $zone) {
$zone->setScope('');
}
$entityManager->flush();
$this->addSql("UPDATE sylius_zone SET scope = NULL WHERE scope = 'all'");
}
}

View file

@ -15,43 +15,16 @@ namespace Sylius\Bundle\CoreBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Sylius\Bundle\CoreBundle\Doctrine\Migrations\AbstractMigration;
use Sylius\Component\Addressing\Model\Scope;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Version20161209095131 extends AbstractMigration implements ContainerAwareInterface
class Version20161209095131 extends AbstractMigration
{
private ?ContainerInterface $container = null;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function up(Schema $schema): void
{
$zoneRepository = $this->container->get('sylius.repository.zone');
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ZoneInterface $zone */
foreach ($zoneRepository->findBy(['scope' => null]) as $zone) {
$zone->setScope(Scope::ALL);
}
$entityManager->flush();
$this->addSql("UPDATE sylius_zone SET scope = 'all' WHERE scope IS NULL");
}
public function down(Schema $schema): void
{
$zoneRepository = $this->container->get('sylius.repository.zone');
$entityManager = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ZoneInterface $zone */
foreach ($zoneRepository->findBy(['scope' => Scope::ALL]) as $zone) {
$zone->setScope('');
}
$entityManager->flush();
$this->addSql("UPDATE sylius_zone SET scope = NULL WHERE scope = 'all'");
}
}