Skip to content

Commit

Permalink
Merge pull request #5 from WeareJH/table-exists-check
Browse files Browse the repository at this point in the history
check if table exists before using it in mysqldump command
  • Loading branch information
Daniel Sloof authored Nov 6, 2019
2 parents 362394e + 223cf2a commit 865407b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Model/DbTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Jh\StrippedDbProvider\Model;

use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ResourceConnection;

class DbTables
{
Expand Down Expand Up @@ -125,15 +126,29 @@ class DbTables
*/
private $deploymentConfig;

public function __construct(DeploymentConfig $deploymentConfig)
/**
* @var ResourceConnection
*/
private $resourceConnection;

public function __construct(DeploymentConfig $deploymentConfig, ResourceConnection $resourceConnection)
{
$this->deploymentConfig = $deploymentConfig;
$this->resourceConnection = $resourceConnection;
}

public function getStructureOnlyTables(): array
{
$configPath = 'system/default/' . Config::XML_PATH_PROJECT_IGNORE_TABLES;
$projectIgnoredTables = $this->deploymentConfig->get($configPath, []);
return array_merge($this->defaultStructureOnlyTables, $projectIgnoredTables);
$tables = array_merge($this->defaultStructureOnlyTables, $projectIgnoredTables);

$connection = $this->resourceConnection->getConnection();
foreach ($tables as $idx => $table) {
if ($connection->isTableExists($table) === false) {
unset($tables[$idx]);
}
}
return $tables;
}
}

0 comments on commit 865407b

Please sign in to comment.