-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from fredden/feature/remove-legacy-stock-rese…
…rvations Automatically truncate the `inventory_reservation` table upon module installation
- Loading branch information
Showing
2 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Ampersand\DisableStockReservation\Setup\Patch\Schema; | ||
|
||
use Magento\Framework\Setup\SchemaSetupInterface; | ||
use Magento\Framework\Setup\Patch\SchemaPatchInterface; | ||
|
||
class RemoveExistingReservations implements SchemaPatchInterface | ||
{ | ||
private const INVENTORY_RESERVATION_TABLE_NAME = 'inventory_reservation'; | ||
private $setup; | ||
|
||
public function __construct( | ||
SchemaSetupInterface $setup | ||
) { | ||
$this->setup = $setup; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function apply() | ||
{ | ||
$connection = $this->setup->getConnection(); | ||
$tableName = $connection->getTableName(self::INVENTORY_RESERVATION_TABLE_NAME); | ||
|
||
if ($connection->isTableExists($tableName)) { | ||
$connection->truncateTable($tableName); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getDependencies(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAliases(): array | ||
{ | ||
return []; | ||
} | ||
} |