ltsecurityinc安防产品在线商城代码
This commit is contained in:
+88
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_GeoIPLookup
|
||||
* @copyright Copyright (c) 2024 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\GeoIPLookup\Setup\Patch\Schema;
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use PDO;
|
||||
|
||||
class RemoveDeprecatedIpTablesFromDatabase implements SchemaPatchInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Setup\SchemaSetupInterface
|
||||
*/
|
||||
private $schemaSetup;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\DB\Adapter\AdapterInterface
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Setup\SchemaSetupInterface $schemaSetup
|
||||
* @param \Magento\Framework\App\ResourceConnection $resourceConnection
|
||||
*/
|
||||
public function __construct(
|
||||
SchemaSetupInterface $schemaSetup,
|
||||
ResourceConnection $resourceConnection
|
||||
) {
|
||||
$this->schemaSetup = $schemaSetup;
|
||||
$this->connection = $resourceConnection->getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function apply(): RemoveDeprecatedIpTablesFromDatabase
|
||||
{
|
||||
$this->schemaSetup->startSetup();
|
||||
|
||||
foreach ($this->getTablesToDelete() as $table) {
|
||||
$this->connection->dropTable($this->connection->getTableName($table));
|
||||
}
|
||||
|
||||
$this->schemaSetup->endSetup();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getDependencies(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAliases(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getTablesToDelete(): array
|
||||
{
|
||||
$tablesToDelete = $this->connection->query(
|
||||
"SHOW TABLES LIKE '{$this->connection->getTableName('prgeoiplookup_maxmindgeoip_city_blocks')}%'"
|
||||
)->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$tablesToDelete[] = 'prgeoiplookup_maxmindgeoip_city_locations';
|
||||
$tablesToDelete[] = 'prgeoiplookup_iptocountry';
|
||||
$tablesToDelete[] = 'prgeoiplookup_installed_versions';
|
||||
|
||||
return $tablesToDelete;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user