DescribeTable.php 1.4 KB

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