Skip to content

Commit

Permalink
CRM-7904: Cannot delete all accounts by mass action (#8546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Perepelytsya authored and yurio committed Mar 16, 2017
1 parent 6a53dd6 commit 4373aee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Oro/Bundle/MagentoBundle/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class Order extends ExtendOrder implements

/**
* @ORM\ManyToOne(targetEntity="Cart")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
protected $cart;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function setExtendExtension(ExtendExtension $extendExtension)
*/
public function getMigrationVersion()
{
return 'v1_45';
return 'v1_46';
}

/**
Expand Down Expand Up @@ -864,7 +864,7 @@ protected function addOrocrmMagentoOrderForeignKeys(Schema $schema)
$schema->getTable('orocrm_magento_cart'),
['cart_id'],
['id'],
[]
['onDelete' => 'CASCADE']
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_user'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Oro\Bundle\MagentoBundle\Migrations\Schema\v1_46;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class SetCascadeDeleteToOrderCartFK implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('orocrm_magento_order');
$fkName = 'FK_4D09F3051AD5CDBF';
$fk = $table->getForeignKey($fkName);
if ($fk->getOption('onDelete') !== 'CASCADE') {
$table->removeForeignKey($fkName);
$table->addForeignKeyConstraint(
$schema->getTable('orocrm_magento_cart'),
['cart_id'],
['id'],
['onDelete' => 'CASCADE']
);
}
}
}

0 comments on commit 4373aee

Please sign in to comment.