Skip to content

Commit 625fa8a

Browse files
author
Sergii Kovalenko
committed
MAGETWO-90684: Upgrade fails if DB contains view
1 parent 0671e73 commit 625fa8a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/DbSchemaReader.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
*/
1818
class DbSchemaReader implements DbSchemaReaderInterface
1919
{
20+
/**
21+
* Table type in information_schema.TABLES which allows to identify only tables and ignore views
22+
*/
23+
const MYSQL_TABLE_TYPE = 'BASE TABLE';
24+
2025
/**
2126
* @var ResourceConnection
2227
*/
@@ -209,8 +214,15 @@ public function readConstraints($tableName, $resource)
209214
*/
210215
public function readTables($resource)
211216
{
212-
return $this->resourceConnection
213-
->getConnection($resource)
214-
->getTables();
217+
$adapter = $this->resourceConnection->getConnection($resource);
218+
$dbName = $this->resourceConnection->getSchemaName($resource);
219+
$stmt = $adapter->select()
220+
->from(
221+
['information_schema.TABLES'],
222+
['TABLE_NAME']
223+
)
224+
->where('TABLE_SCHEMA = ?', $dbName)
225+
->where('TABLE_TYPE = ?', self::MYSQL_TABLE_TYPE);
226+
return $adapter->fetchCol($stmt);
215227
}
216228
}

0 commit comments

Comments
 (0)