Skip to content

Commit

Permalink
add onDelete cascade on foreign key constraint between MenuUpdate and…
Browse files Browse the repository at this point in the history
… Scope
  • Loading branch information
stiteca committed Dec 22, 2020
1 parent ed441d3 commit 766bb20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OroCommerceMenuBundleInstaller implements
*/
public function getMigrationVersion()
{
return 'v1_7';
return 'v1_8';
}

/**
Expand Down Expand Up @@ -188,7 +188,8 @@ protected function addOroCommerceMenuUpdateForeignKeys(Schema $schema)
$table->addForeignKeyConstraint(
$schema->getTable('oro_scope'),
['scope_id'],
['id']
['id'],
['onDelete' => 'SET NULL', 'notnull' => false]
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_web_catalog_content_node'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Oro\Bundle\CommerceMenuBundle\Migrations\Schema\v1_8;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AddScopeToMenuUpdateTable implements Migration
{

/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
/** Table updates **/
$this->addOroCommerceMenuUpdateForeignKeys($schema);
}

/**
* Add oro_commerce_menu_upd foreign keys.
*
* @param Schema $schema
*/
protected function addOroCommerceMenuUpdateForeignKeys(Schema $schema)
{
$table = $schema->getTable('oro_commerce_menu_upd');
$table->addForeignKeyConstraint(
$schema->getTable('oro_scope'),
['scope_id'],
['id'],
['onUpdate' => null, 'onDelete' => 'CASCADE']
);
}
}

0 comments on commit 766bb20

Please sign in to comment.