TableSchemaInterface.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.5.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Database\Schema;
  16. use Cake\Datasource\SchemaInterface;
  17. /**
  18. * An interface used by database TableSchema objects.
  19. *
  20. * Deprecated 3.5.0: Use Cake\Database\TableSchemaAwareInterface instead.
  21. */
  22. interface TableSchemaInterface extends SchemaInterface
  23. {
  24. /**
  25. * Binary column type
  26. *
  27. * @var string
  28. */
  29. const TYPE_BINARY = 'binary';
  30. /**
  31. * Binary UUID column type
  32. *
  33. * @var string
  34. */
  35. const TYPE_BINARY_UUID = 'binaryuuid';
  36. /**
  37. * Date column type
  38. *
  39. * @var string
  40. */
  41. const TYPE_DATE = 'date';
  42. /**
  43. * Datetime column type
  44. *
  45. * @var string
  46. */
  47. const TYPE_DATETIME = 'datetime';
  48. /**
  49. * Time column type
  50. *
  51. * @var string
  52. */
  53. const TYPE_TIME = 'time';
  54. /**
  55. * Timestamp column type
  56. *
  57. * @var string
  58. */
  59. const TYPE_TIMESTAMP = 'timestamp';
  60. /**
  61. * JSON column type
  62. *
  63. * @var string
  64. */
  65. const TYPE_JSON = 'json';
  66. /**
  67. * String column type
  68. *
  69. * @var string
  70. */
  71. const TYPE_STRING = 'string';
  72. /**
  73. * Text column type
  74. *
  75. * @var string
  76. */
  77. const TYPE_TEXT = 'text';
  78. /**
  79. * Tiny Integer column type
  80. *
  81. * @var string
  82. */
  83. const TYPE_TINYINTEGER = 'tinyinteger';
  84. /**
  85. * Small Integer column type
  86. *
  87. * @var string
  88. */
  89. const TYPE_SMALLINTEGER = 'smallinteger';
  90. /**
  91. * Integer column type
  92. *
  93. * @var string
  94. */
  95. const TYPE_INTEGER = 'integer';
  96. /**
  97. * Big Integer column type
  98. *
  99. * @var string
  100. */
  101. const TYPE_BIGINTEGER = 'biginteger';
  102. /**
  103. * Float column type
  104. *
  105. * @var string
  106. */
  107. const TYPE_FLOAT = 'float';
  108. /**
  109. * Decimal column type
  110. *
  111. * @var string
  112. */
  113. const TYPE_DECIMAL = 'decimal';
  114. /**
  115. * Boolean column type
  116. *
  117. * @var string
  118. */
  119. const TYPE_BOOLEAN = 'boolean';
  120. /**
  121. * UUID column type
  122. *
  123. * @var string
  124. */
  125. const TYPE_UUID = 'uuid';
  126. /**
  127. * Check whether or not a table has an autoIncrement column defined.
  128. *
  129. * @return bool
  130. */
  131. public function hasAutoincrement();
  132. /**
  133. * Sets whether the table is temporary in the database.
  134. *
  135. * @param bool $temporary Whether or not the table is to be temporary.
  136. * @return $this
  137. */
  138. public function setTemporary($temporary);
  139. /**
  140. * Gets whether the table is temporary in the database.
  141. *
  142. * @return bool The current temporary setting.
  143. */
  144. public function isTemporary();
  145. /**
  146. * Get the column(s) used for the primary key.
  147. *
  148. * @return array Column name(s) for the primary key. An
  149. * empty list will be returned when the table has no primary key.
  150. */
  151. public function primaryKey();
  152. /**
  153. * Add an index.
  154. *
  155. * Used to add indexes, and full text indexes in platforms that support
  156. * them.
  157. *
  158. * ### Attributes
  159. *
  160. * - `type` The type of index being added.
  161. * - `columns` The columns in the index.
  162. *
  163. * @param string $name The name of the index.
  164. * @param array $attrs The attributes for the index.
  165. * @return $this
  166. */
  167. public function addIndex($name, $attrs);
  168. /**
  169. * Read information about an index based on name.
  170. *
  171. * @param string $name The name of the index.
  172. * @return array|null Array of index data, or null
  173. */
  174. public function getIndex($name);
  175. /**
  176. * Get the names of all the indexes in the table.
  177. *
  178. * @return string[]
  179. */
  180. public function indexes();
  181. /**
  182. * Add a constraint.
  183. *
  184. * Used to add constraints to a table. For example primary keys, unique
  185. * keys and foreign keys.
  186. *
  187. * ### Attributes
  188. *
  189. * - `type` The type of constraint being added.
  190. * - `columns` The columns in the index.
  191. * - `references` The table, column a foreign key references.
  192. * - `update` The behavior on update. Options are 'restrict', 'setNull', 'cascade', 'noAction'.
  193. * - `delete` The behavior on delete. Options are 'restrict', 'setNull', 'cascade', 'noAction'.
  194. *
  195. * The default for 'update' & 'delete' is 'cascade'.
  196. *
  197. * @param string $name The name of the constraint.
  198. * @param array $attrs The attributes for the constraint.
  199. * @return $this
  200. */
  201. public function addConstraint($name, $attrs);
  202. /**
  203. * Read information about a constraint based on name.
  204. *
  205. * @param string $name The name of the constraint.
  206. * @return array|null Array of constraint data, or null
  207. */
  208. public function getConstraint($name);
  209. /**
  210. * Remove a constraint.
  211. *
  212. * @param string $name Name of the constraint to remove
  213. * @return $this
  214. */
  215. public function dropConstraint($name);
  216. /**
  217. * Get the names of all the constraints in the table.
  218. *
  219. * @return string[]
  220. */
  221. public function constraints();
  222. }