Skip to content

Commit

Permalink
add $filterAssetNames to get assert tables
Browse files Browse the repository at this point in the history
add a parameter to can get all tables (with asserts), use for a bug in migrations, TableMetadataStorage appear as not initialized
  • Loading branch information
eltharin committed Jan 17, 2025
1 parent ec16c82 commit 3f5c633
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected function doListTableIndexes($table): array
*
* @throws Exception
*/
public function tablesExist($names)
public function tablesExist($names, bool $filterAssetNames = true)
{
if (is_string($names)) {
Deprecation::trigger(
Expand All @@ -322,7 +322,7 @@ public function tablesExist($names)

$names = array_map('strtolower', (array) $names);

return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames())));
return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames($filterAssetNames))));
}

/**
Expand All @@ -332,31 +332,31 @@ public function tablesExist($names)
*
* @throws Exception
*/
public function listTableNames()
public function listTableNames(bool $filterAssetNames = true)
{
$sql = $this->_platform->getListTablesSQL();

$tables = $this->_conn->fetchAllAssociative($sql);
$tableNames = $this->_getPortableTablesList($tables);

return $this->filterAssetNames($tableNames);
return $filterAssetNames ? $this->filterAssetNames($tableNames) : $tableNames;
}

/**
* @return list<string>
*
* @throws Exception
*/
protected function doListTableNames(): array
protected function doListTableNames(bool $filterAssetNames = true): array
{
$database = $this->getDatabase(__METHOD__);

return $this->filterAssetNames(
$this->_getPortableTablesList(
$this->selectTableNames($database)
->fetchAllAssociative(),
),
$tableNames = $this->_getPortableTablesList(
$this->selectTableNames($database)
->fetchAllAssociative(),
);

return $filterAssetNames ? $this->filterAssetNames($tableNames) : $tableNames;
}

/**
Expand Down

0 comments on commit 3f5c633

Please sign in to comment.