DbSchemaWriterInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Setup\Declaration\Schema\Db;
  7. /**
  8. * This class is responsible for read different schema structural elements: indexes, constraints,
  9. * table names and columns.
  10. */
  11. interface DbSchemaWriterInterface
  12. {
  13. /**
  14. * Type for all alter statements.
  15. */
  16. const ALTER_TYPE = 'alter';
  17. /**
  18. * Type for all create statements.
  19. */
  20. const CREATE_TYPE = 'create';
  21. /**
  22. * Type for all drop statements.
  23. */
  24. const DROP_TYPE = 'drop';
  25. /**
  26. * Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc.
  27. *
  28. * @param $tableName
  29. * @param $resource
  30. * @param array $definition
  31. * @param array $options
  32. * @return Statement
  33. */
  34. public function createTable($tableName, $resource, array $definition, array $options);
  35. /**
  36. * Drop table from SQL database.
  37. *
  38. * @param string $tableName
  39. * @param string $resource
  40. * @return Statement
  41. */
  42. public function dropTable($tableName, $resource);
  43. /**
  44. * Add generic element to table (table must be specified in elementOptions).
  45. *
  46. * Can be: column, constraint, index.
  47. *
  48. * @param string $elementName
  49. * @param string $resource
  50. * @param string $tableName
  51. * @param string $elementDefinition , for example: like CHAR(200) NOT NULL
  52. * @param string $elementType
  53. * @return Statement
  54. */
  55. public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType);
  56. /**
  57. * Return statements which reset auto_increment to 1.
  58. *
  59. * @param string $tableName
  60. * @param string $resource
  61. * @return Statement
  62. */
  63. public function resetAutoIncrement($tableName, $resource);
  64. /**
  65. * Modify column and change it definition.
  66. *
  67. * Note: only column can be modified.
  68. *
  69. * @param string $columnName
  70. * @param string $resource
  71. * @param string $tableName
  72. * @param string $columnDefinition
  73. * @return Statement
  74. */
  75. public function modifyColumn($columnName, $resource, $tableName, $columnDefinition);
  76. /**
  77. * Modify any table option, like comment, engine, etc...
  78. *
  79. * @param string $tableName
  80. * @param string $resource
  81. * @param string $optionName
  82. * @param string $optionValue
  83. * @return Statement
  84. */
  85. public function modifyTableOption($tableName, $resource, $optionName, $optionValue);
  86. /**
  87. * Drop any element (constraint, column, index) from index.
  88. *
  89. * @param string $resource
  90. * @param string $elementName
  91. * @param string $tableName
  92. * @param string $type
  93. * @return Statement
  94. */
  95. public function dropElement($resource, $elementName, $tableName, $type);
  96. /**
  97. * Compile statements and make SQL request from them.
  98. *
  99. * @param StatementAggregator $statementAggregator
  100. * @param bool $dryRun
  101. * @return void
  102. */
  103. public function compile(StatementAggregator $statementAggregator, $dryRun);
  104. }