本文整理汇总了PHP中Oro\Bundle\MigrationBundle\Migration\QueryBag::addPostQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBag::addPostQuery方法的具体用法?PHP QueryBag::addPostQuery怎么用?PHP QueryBag::addPostQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\MigrationBundle\Migration\QueryBag
的用法示例。
在下文中一共展示了QueryBag::addPostQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->createAuditField($schema);
$queries->addPostQuery(new MigrateAuditFieldQuery());
$queries->addPostQuery('ALTER TABLE oro_audit DROP COLUMN data');
$queries->addPostQuery($this->getDropEntityConfigFieldQuery('Oro\\Bundle\\DataAuditBundle\\Entity\\Audit', 'data'));
}
示例2: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$schema->dropTable('oro_calendar_connection');
$calendarConnectionClass = 'Oro\\Bundle\\CalendarBundle\\Entity\\CalendarConnection';
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_field WHERE entity_id IN (' . 'SELECT id FROM oro_entity_config WHERE class_name = :class)', ['class' => $calendarConnectionClass], ['class' => 'string']));
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config WHERE class_name = :class', ['class' => $calendarConnectionClass], ['class' => 'string']));
$queries->addPostQuery(new DeleteAclMigrationQuery($this->container, new ObjectIdentity('entity', $calendarConnectionClass)));
}
示例3: updateConfigs
/**
* Modify entity config to exclude currency and currency_precision fields
*
* @param Schema $schema
* @param QueryBag $queries
*/
public static function updateConfigs(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('oro_organization');
$table->dropColumn('currency');
$table->dropColumn('currency_precision');
if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) {
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('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 IN (:field_names) ' . 'AND oecf.entity_id = (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . '))', ['field_names' => ['precision', 'currency'], 'class_name' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'], ['field_names' => Connection::PARAM_STR_ARRAY, 'class_name' => Type::STRING]));
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_field ' . 'WHERE field_name IN (:field_names) ' . 'AND entity_id IN (' . 'SELECT id FROM oro_entity_config WHERE class_name = :class_name' . ')', ['field_names' => ['precision', 'currency'], 'class_name' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'], ['field_names' => Connection::PARAM_STR_ARRAY, 'class_name' => Type::STRING]));
}
}
示例4: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('oro_calendar_property');
$table->getColumn('background_color')->setOptions(['length' => 7]);
$table->dropColumn('color');
$table = $schema->getTable('oro_calendar_event');
$table->addColumn('background_color', 'string', ['notnull' => false, 'length' => 7]);
$queries->addPostQuery($this->getUpdateBackgroundColorValuesQuery());
$queries->addPostQuery($this->getDropEntityConfigFieldQuery('Oro\\Bundle\\CalendarBundle\\Entity\\CalendarProperty', 'color'));
}
示例5: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('orocrm_magento_order_items');
$table->addColumn('owner_id', 'integer', ['notnull' => false]);
$table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []);
$table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL']);
$queries->addPostQuery('UPDATE orocrm_magento_order_items itm ' . 'SET owner_id = (SELECT organization_id FROM orocrm_magento_order WHERE itm.order_id = id)');
$table = $schema->getTable('orocrm_magento_cart_item');
$table->addColumn('owner_id', 'integer', ['notnull' => false]);
$table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []);
$table->addForeignKeyConstraint($schema->getTable('oro_organization'), ['owner_id'], ['id'], ['onDelete' => 'SET NULL']);
$queries->addPostQuery('UPDATE orocrm_magento_cart_item itm ' . 'SET owner_id = (SELECT organization_id FROM orocrm_magento_cart WHERE itm.cart_id = id)');
}
示例6: up
/**
* @inheritdoc
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->modifyOrocrmSalesLeadTable($schema);
$this->modifyOrocrmSalesOpportunityTable($schema);
$this->modifyOrocrmSalesSalesFunnelTable($schema);
$queries->addPostQuery(new MigrateAccountRelations());
}
示例7: changePrimaryKeyType
/**
* @param Schema $schema
* @param QueryBag $queries
* @param string $tableName
* @param string $columnName
* @param string $type
*
* @throws \Exception
*/
public function changePrimaryKeyType(Schema $schema, QueryBag $queries, $tableName, $columnName, $type)
{
$targetColumn = $schema->getTable($tableName)->getColumn($columnName);
$type = Type::getType($type);
if ($targetColumn->getType() === $type) {
return;
}
/** @var ForeignKeyConstraint[] $foreignKeys */
$foreignKeys = [];
foreach ($schema->getTables() as $table) {
/** @var ForeignKeyConstraint[] $tableForeignKeys */
$tableForeignKeys = array_filter($table->getForeignKeys(), function (ForeignKeyConstraint $tableForeignKey) use($tableName, $columnName) {
if ($tableForeignKey->getForeignTableName() !== $tableName) {
return false;
}
return $tableForeignKey->getForeignColumns() === [$columnName];
});
foreach ($tableForeignKeys as $tableForeignKey) {
$foreignKeys[$tableForeignKey->getName()] = $tableForeignKey;
$foreignKeyTableName = $tableForeignKey->getLocalTable()->getName();
$foreignKeyColumnNames = $tableForeignKey->getLocalColumns();
$queries->addPreQuery($this->platform->getDropForeignKeySQL($tableForeignKey, $foreignKeyTableName));
$column = $schema->getTable($foreignKeyTableName)->getColumn(reset($foreignKeyColumnNames));
if ($column instanceof ExtendColumn) {
$column->disableExtendOptions()->setType($type)->enableExtendOptions();
} else {
$column->setType($type);
}
}
}
$targetColumn->setType($type);
foreach ($foreignKeys as $foreignKey) {
$queries->addPostQuery($this->platform->getCreateForeignKeySQL($foreignKey, $foreignKey->getLocalTable()));
}
}
示例8: updateConfigs
/**
* Modify entity config to exclude currency and currency_precision fields
*
* @param Schema $schema
* @param QueryBag $queries
*/
public static function updateConfigs(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('oro_organization');
$table->dropColumn('currency');
$table->dropColumn('currency_precision');
if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) {
$queries->addPostQuery('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 = \'precision\' OR oecf.field_name = \'currency\')
AND
oecf.entity_id = (
SELECT oec.id
FROM oro_entity_config AS oec
WHERE oec.class_name = \'Oro\\\\Bundle\\\\OrganizationBundle\\\\Entity\\\\Organization\'
)
);
DELETE FROM oro_entity_config_field
WHERE
field_name IN (\'precision\', \'currency\')
AND
entity_id IN (
SELECT id
FROM oro_entity_config
WHERE class_name = \'Oro\\\\Bundle\\\\OrganizationBundle\\\\Entity\\\\Organization\'
)');
}
}
示例9: updateNavigationHistory
/**
* Update navigation history with route names and parameters
*
* @param QueryBag $queries
*/
protected function updateNavigationHistory(QueryBag $queries)
{
$queryBuilder = $this->em->getRepository('OroNavigationBundle:NavigationHistoryItem')->createQueryBuilder('h')->select('h.id, h.url');
$paginator = new Paginator($queryBuilder, false);
foreach ($paginator as $navItem) {
try {
$url = str_replace('app_dev.php/', '', $navItem['url']);
$routeData = $this->router->match($url);
$entityId = isset($routeData['id']) ? (int) $routeData['id'] : null;
$route = $routeData['_route'];
unset($routeData['_controller'], $routeData['id'], $routeData['_route']);
$queries->addPostQuery(sprintf('UPDATE oro_navigation_history ' . 'SET route = \'%s\', entity_id = %d, route_parameters=\'%s\' WHERE id = %d', $route, $entityId, serialize($routeData), $navItem['id']));
} catch (\RuntimeException $e) {
$queries->addPostQuery(sprintf('UPDATE oro_navigation_history SET route_parameters = \'%s\' WHERE id=%d', serialize([]), $navItem['id']));
}
}
}
示例10: removeRoleOwner
public static function removeRoleOwner(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('oro_access_role');
if ($table->hasColumn('business_unit_owner_id')) {
$queries->addQuery(new UpdateRoleOwnerQuery());
if ($table->hasForeignKey('FK_673F65E759294170')) {
$table->removeForeignKey('FK_673F65E759294170');
}
if ($table->hasIndex('IDX_F82840BC59294170')) {
$table->dropIndex('IDX_F82840BC59294170');
}
$table->dropColumn('business_unit_owner_id');
if ($schema->hasTable('oro_entity_config_index_value') && $schema->hasTable('oro_entity_config_field')) {
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('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_name ' . 'AND oecf.entity_id IN (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . '))', ['field_name' => 'owner', 'class_name' => 'Oro\\Bundle\\UserBundle\\Entity\\Role'], ['field_name' => 'string', 'class_name' => 'string']));
$queries->addPostQuery(new ParametrizedSqlMigrationQuery('DELETE FROM oro_entity_config_field ' . 'WHERE field_name = :field_name ' . 'AND entity_id IN (' . 'SELECT oec.id FROM oro_entity_config AS oec WHERE oec.class_name = :class_name' . ')', ['field_name' => 'owner', 'class_name' => 'Oro\\Bundle\\UserBundle\\Entity\\Role'], ['field_name' => 'string', 'class_name' => 'string']));
}
}
}
示例11: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
/**
* After v1_3 migration
* Undefined table: 7 ERROR: relation "oro_dashboard_active_id_seq" does not exist
*/
if ($this->platform->supportsSequences()) {
$queries->addPostQuery('ALTER SEQUENCE IF EXISTS oro_dashboard_active_copy_id_seq RENAME TO oro_dashboard_active_id_seq;');
}
}
示例12: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
// Copy values from VAT to temp auxiliary column with correction
$query = 'UPDATE orocrm_magento_customer ' . 'SET vat_temp = ROUND(vat * 100.0) ' . 'WHERE vat IS NOT NULL';
$queries->addPreQuery($query);
// Change data type of the VAT column
$schema->getTable('orocrm_magento_customer')->getColumn('vat')->setType(Type::getType(Type::STRING));
// Copy values back to VAT column
$query = 'UPDATE orocrm_magento_customer ' . 'SET vat = vat_temp ' . 'WHERE vat IS NOT NULL';
$queries->addPostQuery($query);
}
示例13: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$queries->addPreQuery($this->getFillUserActivityQuery());
$queries->addPreQuery($this->getFillAccountActivityQuery());
$queries->addPreQuery($this->getFillContactActivityQuery());
$queries->addPreQuery($this->getFillPhoneQuery());
$callTable = $schema->getTable('orocrm_call');
// relation with account
$callTable->removeForeignKey('FK_1FBD1A2411A6570A');
$callTable->dropColumn('related_account_id');
$queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('relatedAccount'));
// relation with contact
$callTable->removeForeignKey('FK_1FBD1A246D6C2DFA');
$callTable->dropColumn('related_contact_id');
$queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('relatedContact'));
// relation with contact phone
$callTable->removeForeignKey('FK_1FBD1A24A156BF5C');
$callTable->dropColumn('contact_phone_id');
$queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('contactPhoneNumber'));
}
示例14: up
/**
* {@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);
}
示例15: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
// update data in accordance with new column requirement
$queries->addPreQuery(sprintf("UPDATE oro_email SET message_id = CONCAT('id.', REPLACE(%s, '-',''), '%s') WHERE message_id IS NULL", $this->platform->getGuidExpression(), '@bap.migration.generated'));
self::oroEmailToFolderRelationTable($schema);
// make message_id not null & add index
$table = $schema->getTable('oro_email');
$table->changeColumn('message_id', ['notnull' => true]);
$table->addIndex(['message_id'], 'IDX_email_message_id', []);
// migrate existing email-folder relations
$queries->addPostQuery("INSERT INTO oro_email_to_folder (email_id, emailfolder_id) SELECT id, folder_id FROM oro_email");
}