public function postUp(Schema $schema)
 {
     $helper = new UpgradeHelper($this->container);
     if ($helper->areProductsStoredInMongo()) {
         $database = $helper->getMongoInstance();
         $this->normalizeProductStatuses($database);
     }
 }
 public function postUp(Schema $schema)
 {
     $upgradeHelper = new UpgradeHelper($this->container);
     if ($upgradeHelper->areProductsStoredInMongo()) {
         $database = $upgradeHelper->getMongoInstance();
         $this->removeFilePathFromProductMedias($database);
     }
 }
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $upgradeHelper = new UpgradeHelper($this->container);
     if ($upgradeHelper->areProductsStoredInMongo()) {
         return;
     }
     $this->addSql('ALTER TABLE pim_catalog_metric CHANGE data data NUMERIC(24, 12) DEFAULT NULL, CHANGE base_data base_data NUMERIC(24, 12) DEFAULT NULL');
 }
 public function postUp(Schema $schema)
 {
     $helper = new UpgradeHelper($this->container);
     if ($helper->areProductsStoredInMongo()) {
         $database = $helper->getMongoInstance();
         $versionCollection = new \MongoCollection($database, 'pim_versioning_version');
         foreach ($this->movedEntities as $source => $target) {
             $result = $versionCollection->update(['resourceName' => $source], ['$set' => ['resourceName' => $target]], ['multiple' => true]);
         }
     }
 }
Esempio n. 5
0
 /**
  * Get the table or collection name of a resource by looking at the class metadata of the entities and documents.
  *
  * @param string $resource
  *
  * @return string
  */
 public function getTableOrCollection($resource)
 {
     if (!array_key_exists($resource, $this->classMapping)) {
         $error = 'Can not get the table for the object "%s". Only the following types %s are known.';
         throw new \InvalidArgumentException(sprintf($error, $resource, implode(', ', array_keys($this->classMapping))));
     }
     if ($this->upgradeHelper->areProductsStoredInMongo() && in_array($resource, $this->productResources)) {
         return $this->getTableOrCollectionForMongo($resource);
     }
     return $this->getTableOrCollectionForOrm($resource);
 }
 /**
  * @param Schema $schema
  */
 public function postUp(Schema $schema)
 {
     $upgradeHelper = new UpgradeHelper($this->container);
     if ($upgradeHelper->areProductsStoredInMongo()) {
         $database = $upgradeHelper->getMongoInstance();
         $tableHelper = new SchemaHelper($this->container);
         echo "Add index to Version document on column loggetAt...\n";
         $versionCollection = new \MongoCollection($database, $tableHelper->getTableOrCollection('version'));
         $versionCollection->ensureIndex(['loggedAt' => -1], ['background' => true]);
         echo "Done.";
     }
 }
 /**
  * Link files to the product values.
  *
  * @param string $productValueTable
  * @param string $productMediaTable
  * @param string $fkMedia
  */
 public function migrateMediasOnProductValue($productValueTable, $productMediaTable, $fkMedia)
 {
     if ($this->upgradeHelper->areProductsStoredInMongo()) {
         $this->migrateMediasOnProductValueMongo($productValueTable);
     } else {
         $this->migrateMediasOnProductValueOrm($productValueTable, $productMediaTable, $fkMedia);
     }
 }