mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
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:
commit
009bc95e21
2 changed files with 6 additions and 61 deletions
|
|
@ -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'");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue