|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Magento\CatalogRule\Setup\Patch\Schema; |
| 8 | + |
| 9 | +use Magento\Framework\Setup\ModuleDataSetupInterface; |
| 10 | +use Magento\Framework\Setup\Patch\SchemaPatchInterface; |
| 11 | + |
| 12 | +class CleanUpProductPriceReplicaTable implements SchemaPatchInterface |
| 13 | +{ |
| 14 | + /** @var ModuleDataSetupInterface */ |
| 15 | + private ModuleDataSetupInterface $moduleDataSetup; |
| 16 | + |
| 17 | + /** |
| 18 | + * @param ModuleDataSetupInterface $moduleDataSetup |
| 19 | + */ |
| 20 | + public function __construct( |
| 21 | + ModuleDataSetupInterface $moduleDataSetup |
| 22 | + ) { |
| 23 | + $this->moduleDataSetup = $moduleDataSetup; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @inheritDoc |
| 28 | + */ |
| 29 | + public function apply(): void |
| 30 | + { |
| 31 | + $connection = $this->moduleDataSetup->getConnection(); |
| 32 | + $connection->startSetup(); |
| 33 | + |
| 34 | + // There was a bug which caused the catalogrule_product_price_replica |
| 35 | + // table to become unnecessarily large. The bug causing the growth has |
| 36 | + // been resolved. This schema patch cleans up the damage done by that |
| 37 | + // bug on existing websites. Deleting all entries from the replica table |
| 38 | + // is safe. |
| 39 | + // See https://github.com/magento/magento2/issues/31752 for details. |
| 40 | + |
| 41 | + $tableName = $connection->getTableName('catalogrule_product_price_replica'); |
| 42 | + |
| 43 | + if ($connection->isTableExists($tableName)) { |
| 44 | + $connection->truncateTable($tableName); |
| 45 | + } |
| 46 | + |
| 47 | + $connection->endSetup(); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @inheritDoc |
| 52 | + */ |
| 53 | + public static function getDependencies(): array |
| 54 | + { |
| 55 | + return []; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @inheritDoc |
| 60 | + */ |
| 61 | + public function getAliases(): array |
| 62 | + { |
| 63 | + return []; |
| 64 | + } |
| 65 | +} |
0 commit comments