Programming Language PHP
Namespace Oro\Bundle\CRMBundle\Migration
Class CleanupMagentoOneConnectorEntities
Total Examples 2
2 code examples of PHP Oro\Bundle\CRMBundle\Migration\CleanupMagentoOneConnectorEntities extracted from open source projects
/**
* @throws \Doctrine\DBAL\Schema\SchemaException if fails to alter database schema
*/
public function up(Schema $schema, QueryBag $queries)
{
if (\class_exists('Oro\Bundle\MagentoBundle\OroMagentoBundle', false)) {
return;
}
foreach (CleanupMagentoOneConnectorEntities::getQueries(true) as $query) {
$queries->addQuery($query);
}
foreach (CleanupMagentoOneConnectorEntityConfigsQuery::ENTITY_CLASSES as $className) {
$queries->addQuery(
new ParametrizedSqlMigrationQuery(
'DELETE FROM orocrm_channel_entity_name WHERE name = :name',
['name' => $className],
['name' => Types::STRING]
)
);
$queries->addQuery(
new ParametrizedSqlMigrationQuery(
'DELETE FROM oro_process_definition WHERE related_entity = :related_entity',
['related_entity' => $className],
['related_entity' => Types::STRING]
)
);
$queries->addQuery(new RemoveWorkflowDefinitionsForRelatedEntityQuery($className));
}
$table = $schema->getTable('oro_integration_transport');
$table->dropColumn('wsdl_url'); // before 1_49 version of MagentoBundle migration
$table->dropColumn('api_url'); // since 1_49 version of MagentoBundle migration
$table->dropColumn('api_user');
$table->dropColumn('api_key');
$table->dropColumn('sync_start_date');
$table->dropColumn('sync_range');
$table->dropColumn('website_id');
$table->dropColumn('websites');
$table->dropColumn('is_extension_installed');
$table->dropColumn('is_wsi_mode');
$table->dropColumn('admin_url');
$table->dropColumn('initial_sync_start_date');
$table->dropColumn('extension_version');
$table->dropColumn('magento_version');
$table->dropColumn('guest_customer_sync');
$table->dropColumn('mage_newsl_subscr_synced_to_id');
$table->dropColumn('api_token');
$table->dropColumn('is_display_order_notes');
$table->dropColumn('shared_guest_email_list');
}
private function getImplementedQueriesToCleanup(Connection $connection): \Generator
{
foreach (CleanupMagentoOneConnectorEntities::getQueries(false) as $query) {
$classReflection = new \ReflectionObject($query);
if ($query instanceof RemoveAssociationQuery
&& $classReflection->hasProperty('sourceEntityClass')
) {
$activityClass = $classReflection->getProperty('sourceEntityClass');
$activityClass->setAccessible(true);
$activityClassValue = $activityClass->getValue($query);
$activityClass->setAccessible(false);
$tableName = $this->getEntityTableName($activityClassValue);
if ($tableName && !SafeDatabaseChecker::tablesExist($connection, $tableName)) {
continue;
}
}
yield $query;
}
}