1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestFramework\Deploy;
use Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DbSchemaReader;
/**
* The purpose of this class is adding test modules files to Magento code base.
*/
class DescribeTable
{
/**
* Schema reader.
*
* @var DbSchemaReader
*/
private $dbSchemaReader;
/**
* This registry is used to ignore some tables, during comparison
*
* @var array
*/
private static $ignoredSystemTables = ['cache', 'cache_tag', 'flag', 'session', 'setup_module', 'patch_list'];
/**
* Constructor.
*
* @param DbSchemaReader $dbSchemaReader
*/
public function __construct(DbSchemaReader $dbSchemaReader)
{
$this->dbSchemaReader = $dbSchemaReader;
}
/**
* Describe shards.
*
* @param string $shardName
* @return array
*/
public function describeShard($shardName)
{
$data = [];
$tables = $this->dbSchemaReader->readTables($shardName);
foreach ($tables as $table) {
if (in_array($table, self::$ignoredSystemTables)) {
continue;
}
$data[$table] = $this->dbSchemaReader->getCreateTableSql($table, $shardName)['Create Table'];
}
return $data;
}
}