partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit baabec0a9cca9da628e295784157b261471ae0e0
parent 0d9fe21c5ce25fc72bcf9639c4517b04b7f3e156
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed,  7 Oct 2015 17:21:48 +0200

Create missing root nodes during migration

Diffstat:
Msrc/PartKeepr/CoreBundle/DoctrineMigrations/BaseMigration.php | 7++++++-
Msrc/PartKeepr/CoreBundle/DoctrineMigrations/Version20150708120022.php | 14++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/PartKeepr/CoreBundle/DoctrineMigrations/BaseMigration.php b/src/PartKeepr/CoreBundle/DoctrineMigrations/BaseMigration.php @@ -3,8 +3,8 @@ namespace PartKeepr\CoreBundle\DoctrineMigrations; use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\ORM\EntityManager; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; abstract class BaseMigration extends AbstractMigration implements ContainerAwareInterface @@ -19,6 +19,11 @@ abstract class BaseMigration extends AbstractMigration implements ContainerAware $this->container = $container; } + public function getContainer() + { + return $this->container; + } + protected function performDatabaseUpgrade() { /** diff --git a/src/PartKeepr/CoreBundle/DoctrineMigrations/Version20150708120022.php b/src/PartKeepr/CoreBundle/DoctrineMigrations/Version20150708120022.php @@ -17,6 +17,17 @@ class Version20150708120022 extends BaseMigration $this->fixTree("PartCategory"); $this->fixTree("FootprintCategory"); + $this->fixTree("StorageLocationCategory"); + + $this->createRootNode("partkeepr.part.category_service"); + $this->createRootNode("partkeepr.storage_location.category_service"); + $this->createRootNode("partkeepr.footprint.category_service"); + + } + + protected function createRootNode($service) + { + $this->getContainer()->get($service)->ensureRootNodeExists(); } /** @@ -67,6 +78,7 @@ class Version20150708120022 extends BaseMigration /** * Fetches the parent node for a table and ID + * * @param $table * @param $id * @@ -90,6 +102,7 @@ class Version20150708120022 extends BaseMigration /** * Returns the node IDs for the table + * * @param $table * * @return array @@ -107,6 +120,7 @@ class Version20150708120022 extends BaseMigration /** * Returns the level for a given table and ID + * * @param $table * @param $id *