Skip to content

Commit 6b14118

Browse files
MarianaMariana
authored andcommitted
Merge branch 'MAGETWO-95311' into mpi-forwardport-1010
2 parents a8fe851 + 4333c92 commit 6b14118

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Wishlist\Setup\Patch\Schema;
9+
10+
use Magento\Framework\DB\Adapter\AdapterInterface;
11+
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
12+
use Magento\Framework\Setup\SchemaSetupInterface;
13+
14+
/**
15+
* Class AddProductIdConstraint
16+
*/
17+
class AddProductIdConstraint implements SchemaPatchInterface
18+
{
19+
/**
20+
* @var SchemaSetupInterface
21+
*/
22+
private $schemaSetup;
23+
24+
/**
25+
* @param SchemaSetupInterface $schemaSetup
26+
*/
27+
public function __construct(
28+
SchemaSetupInterface $schemaSetup
29+
) {
30+
$this->schemaSetup = $schemaSetup;
31+
}
32+
33+
/**
34+
* Run code inside patch.
35+
*
36+
* @return void
37+
*/
38+
public function apply()
39+
{
40+
$this->schemaSetup->startSetup();
41+
42+
$this->schemaSetup->getConnection()->addForeignKey(
43+
$this->schemaSetup->getConnection()->getForeignKeyName(
44+
$this->schemaSetup->getTable('wishlist_item_option'),
45+
'product_id',
46+
$this->schemaSetup->getTable('catalog_product_entity'),
47+
'entity_id'
48+
),
49+
$this->schemaSetup->getTable('wishlist_item_option'),
50+
'product_id',
51+
$this->schemaSetup->getTable('catalog_product_entity'),
52+
'entity_id',
53+
AdapterInterface::FK_ACTION_CASCADE,
54+
true
55+
);
56+
57+
$this->schemaSetup->endSetup();
58+
}
59+
60+
/**
61+
* Get array of patches that have to be executed prior to this.
62+
*
63+
* @return string[]
64+
*/
65+
public static function getDependencies()
66+
{
67+
return [];
68+
}
69+
70+
/**
71+
* Get aliases (previous names) for the patch.
72+
*
73+
* @return string[]
74+
*/
75+
public function getAliases()
76+
{
77+
return [];
78+
}
79+
}

app/code/Magento/Wishlist/etc/db_schema_whitelist.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
"PRIMARY": true,
3636
"WISHLIST_ITEM_WISHLIST_ID_WISHLIST_WISHLIST_ID": true,
3737
"WISHLIST_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID": true,
38-
"WISHLIST_ITEM_STORE_ID_STORE_STORE_ID": true,
39-
"WISHLIST_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE": true
38+
"WISHLIST_ITEM_STORE_ID_STORE_STORE_ID": true
4039
}
4140
},
4241
"wishlist_item_option": {
@@ -49,7 +48,8 @@
4948
},
5049
"constraint": {
5150
"PRIMARY": true,
52-
"FK_A014B30B04B72DD0EAB3EECD779728D6": true
51+
"FK_A014B30B04B72DD0EAB3EECD779728D6": true,
52+
"WISHLIST_ITEM_OPTION_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID": true
5353
}
5454
}
5555
}

0 commit comments

Comments
 (0)