Skip to content

Commit 4b0cf77

Browse files
committed
Merge branch '31752-clean-up-old-data' of github.com:fredden/magento2 into 2.4-develop-prs
2 parents d0edf38 + e2914a7 commit 4b0cf77

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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\CatalogRule\Setup\Patch\Schema;
9+
10+
use Magento\Framework\Setup\SchemaSetupInterface;
11+
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
12+
13+
class CleanUpProductPriceReplicaTable implements SchemaPatchInterface
14+
{
15+
/**
16+
* @var SchemaSetupInterface
17+
*/
18+
private SchemaSetupInterface $schemaSetup;
19+
20+
/**
21+
* CleanUpProductPriceReplicaTable constructor.
22+
* @param SchemaSetupInterface $schemaSetup
23+
*/
24+
public function __construct(
25+
SchemaSetupInterface $schemaSetup
26+
) {
27+
$this->schemaSetup = $schemaSetup;
28+
}
29+
30+
/**
31+
* @inheritDoc
32+
*/
33+
public function apply(): void
34+
{
35+
$connection = $this->schemaSetup->startSetup();
36+
$connection = $this->schemaSetup->getConnection();
37+
38+
// There was a bug which caused the catalogrule_product_price_replica
39+
// table to become unnecessarily large. The bug causing the growth has
40+
// been resolved. This schema patch cleans up the damage done by that
41+
// bug on existing websites. Deleting all entries from the replica table
42+
// is safe.
43+
// See https://github.com/magento/magento2/issues/31752 for details.
44+
45+
$tableName = $connection->getTableName('catalogrule_product_price_replica');
46+
47+
if ($connection->isTableExists($tableName)) {
48+
$connection->truncateTable($tableName);
49+
}
50+
51+
$connection->endSetup();
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public static function getDependencies(): array
58+
{
59+
return [];
60+
}
61+
62+
/**
63+
* @inheritDoc
64+
*/
65+
public function getAliases(): array
66+
{
67+
return [];
68+
}
69+
}

0 commit comments

Comments
 (0)