|
| 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 | +} |
0 commit comments