Ejemplo n.º 1
0
 /**
  * @param string $className
  * @param string $fieldName
  *
  * @return ParametrizedSqlMigrationQuery
  */
 private function getDropEntityConfigFieldQuery($className, $fieldName)
 {
     $dropFieldIndexSql = 'DELETE FROM oro_entity_config_index_value' . ' WHERE entity_id IS NULL AND field_id IN (' . ' SELECT oecf.id FROM oro_entity_config_field AS oecf' . ' WHERE oecf.field_name = :field' . ' AND oecf.entity_id IN (' . ' SELECT oec.id' . ' FROM oro_entity_config AS oec' . ' WHERE oec.class_name = :class' . ' ))';
     $dropFieldSql = 'DELETE FROM oro_entity_config_field' . ' WHERE field_name = :field' . ' AND entity_id IN (' . ' SELECT id' . ' FROM oro_entity_config' . ' WHERE class_name = :class' . ' )';
     $query = new ParametrizedSqlMigrationQuery();
     $query->addSql($dropFieldIndexSql, ['field' => $fieldName, 'class' => $className], ['field' => 'string', 'class' => 'string']);
     $query->addSql($dropFieldSql, ['field' => $fieldName, 'class' => $className], ['field' => 'string', 'class' => 'string']);
     return $query;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $className = 'OroCRM\\Bundle\\MagentoBundle\\Entity\\MagentoSoapTransport';
     $dropFieldsSql = 'DELETE FROM oro_entity_config_field' . ' WHERE entity_id IN (' . ' SELECT id' . ' FROM oro_entity_config' . ' WHERE class_name = :class' . ' )';
     $dropFieldsQuery = new ParametrizedSqlMigrationQuery();
     $dropFieldsQuery->addSql($dropFieldsSql, ['class' => $className], ['class' => 'string']);
     $queries->addPostQuery($dropFieldsQuery);
     $dropConfigurationSql = 'DELETE FROM oro_entity_config WHERE class_name = :class';
     $dropConfigurationQuery = new ParametrizedSqlMigrationQuery();
     $dropConfigurationQuery->addSql($dropConfigurationSql, ['class' => $className], ['class' => 'string']);
     $queries->addQuery($dropConfigurationQuery);
 }
Ejemplo n.º 3
0
    /**
     * {@inheritdoc}
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        foreach ($this->fields as $fieldName => $entityClasses) {
            foreach ($entityClasses as $entityClass) {
                $dropFieldsSql = <<<EOF
DELETE FROM oro_entity_config_field
WHERE field_name = :field_name
AND entity_id IN (SELECT id FROM oro_entity_config WHERE class_name = :class_name)
EOF;
                $dropFieldsQuery = new ParametrizedSqlMigrationQuery();
                $dropFieldsQuery->addSql($dropFieldsSql, ['field_name' => $fieldName, 'class_name' => $entityClass], ['field_name' => Type::STRING, 'class_name' => Type::STRING]);
                $queries->addPostQuery($dropFieldsQuery);
            }
        }
    }
 protected function addSqls(ParametrizedSqlMigrationQuery $query)
 {
     $query->addSql('INSERT INTO test_table (name) VALUES (\'name\')');
     $query->addSql('INSERT INTO test_table (name) VALUES (?1)', ['test']);
     $query->addSql('INSERT INTO test_table (name) VALUES (?1)', ['test'], ['string']);
     $query->addSql('INSERT INTO test_table (name) VALUES (:name)', ['name' => 'test']);
     $query->addSql('INSERT INTO test_table (name) VALUES (:name)', ['name' => 'test'], ['name' => 'string']);
     $query->addSql('UPDATE test_table SET values = ?1 WHERE id = ?2', [[1, 2, 3], 1], ['array', 'integer']);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('orocrm_magento_order');
     $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $updateDates = 'UPDATE orocrm_magento_order SET imported_at = created_at, synced_at = updated_at';
     $updateDatesQuery = new ParametrizedSqlMigrationQuery();
     $updateDatesQuery->addSql($updateDates);
     $queries->addPostQuery($updateDatesQuery);
     $table = $schema->getTable('orocrm_magento_customer');
     $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $updateDates = 'UPDATE orocrm_magento_customer SET imported_at = created_at, synced_at = updated_at';
     $updateDatesQuery = new ParametrizedSqlMigrationQuery();
     $updateDatesQuery->addSql($updateDates);
     $queries->addPostQuery($updateDatesQuery);
     $table = $schema->getTable('orocrm_magento_cart');
     $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
     $updateDates = 'UPDATE orocrm_magento_cart SET imported_at = createdat, synced_at = updatedat';
     $updateDatesQuery = new ParametrizedSqlMigrationQuery();
     $updateDatesQuery->addSql($updateDates);
     $queries->addPostQuery($updateDatesQuery);
 }
 /**
  * {@inheritdoc}
  */
 protected function processQueries(LoggerInterface $logger, $dryRun = false)
 {
     $segments = $this->connection->createQueryBuilder()->select('s.id, s.definition')->from('oro_segment', 's')->execute()->fetchAll(\PDO::FETCH_ASSOC);
     $segmentsToUpdate = [];
     foreach ($segments as $segment) {
         $definition = $segment['definition'];
         $needUpdate = false;
         if ($definition) {
             $definition = $this->connection->convertToPHPValue($definition, Type::JSON_ARRAY);
             if (!empty($definition['filters'])) {
                 $updated = $this->processFilters($definition['filters'], $needUpdate);
                 if ($needUpdate) {
                     $definition['filters'] = $updated;
                     $segmentsToUpdate[$segment['id']] = $definition;
                 }
             }
         }
     }
     foreach ($segmentsToUpdate as $id => $definitionToUpdate) {
         $this->addSql('UPDATE oro_segment SET definition = :definition WHERE id = :id', ['id' => $id, 'definition' => $definitionToUpdate], ['id' => Type::INTEGER, 'definition' => Type::JSON_ARRAY]);
     }
     parent::processQueries($logger, $dryRun);
 }
 /**
  * {@inheritdoc}
  */
 protected function processQueries(LoggerInterface $logger, $dryRun = false)
 {
     $this->addSql('UPDATE oro_email_template SET user_owner_id = (' . $this->getAdminUserQuery() . ')', ['role' => User::ROLE_ADMINISTRATOR], ['role' => Type::STRING]);
     parent::processQueries($logger, $dryRun);
 }
Ejemplo n.º 8
0
 /**
  * @param string $fieldName
  *
  * @return ParametrizedSqlMigrationQuery
  */
 protected function getDropEntityConfigManyToOneRelationQuery($fieldName)
 {
     $dropFieldIndexSql = 'DELETE FROM oro_entity_config_index_value' . ' WHERE entity_id IS NULL AND field_id IN (' . ' SELECT oecf.id FROM oro_entity_config_field AS oecf' . ' WHERE oecf.field_name = :field' . ' AND oecf.entity_id IN (' . ' SELECT oec.id' . ' FROM oro_entity_config AS oec' . ' WHERE oec.class_name = :class' . ' ))';
     $dropFieldSql = 'DELETE FROM oro_entity_config_field' . ' WHERE field_name = :field' . ' AND entity_id IN (' . ' SELECT id' . ' FROM oro_entity_config' . ' WHERE class_name = :class' . ' )';
     $taskClassName = $this->extendExtension->getEntityClassByTableName('orocrm_task');
     $query = new ParametrizedSqlMigrationQuery();
     $query->addSql($dropFieldIndexSql, ['field' => $fieldName, 'class' => $taskClassName], ['field' => 'string', 'class' => 'string']);
     $query->addSql($dropFieldSql, ['field' => $fieldName, 'class' => $taskClassName], ['field' => 'string', 'class' => 'string']);
     return $query;
 }