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