Add PHP API to update database tables
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / database / table / column / IDatabaseTableColumn.class.php
CommitLineData
f6e43f2f
MS
1<?php
2namespace wcf\system\database\table\column;
3
4/**
5 * Represents a column of a database table.
6 *
7 * @author Matthias Schmidt
8 * @copyright 2001-2019 WoltLab GmbH
9 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
10 * @package WoltLabSuite\Core\System\Database\Table\Column
11 * @since 5.2
12 */
13interface IDatabaseTableColumn {
14 /**
15 * Sets the default value of the column and returns the column.
16 *
17 * @param mixed $defaultValue
18 * @return $this
19 */
20 public function defaultValue($defaultValue);
21
22 /**
23 * Marks the column to be dropped and returns the column.
24 *
25 * @return $this
26 */
27 public function drop();
28
29 /**
30 * Returns the data used by `DatabaseEditor` to add the column to a table.
31 *
32 * @return array
33 */
34 public function getData();
35
36 /**
37 * Returns the default value of the column.
38 *
39 * @return $this
40 */
41 public function getDefaultValue();
42
43 /**
44 * Returns the name of the column.
45 *
46 * @return string
47 */
48 public function getName();
49
50 /**
51 * Returns the type of the column.
52 *
53 * @return string
54 */
55 public function getType();
56
57 /**
58 * Returns `true` if the values of the column cannot be `null`.
59 *
60 * @return bool
61 */
62 public function isNotNull();
63
64 /**
65 * Sets the name of the column and returns the column.
66 *
67 * @param string $name
68 * @return $this
69 */
70 public function name($name);
71
72 /**
73 * Sets if the values of the column cannot be `null`.
74 *
75 * @param bool $notNull
76 * @return $this
77 */
78 public function notNull($notNull = true);
79
80 /**
81 * Returns `true` if the column will be dropped.
82 *
83 * @return bool
84 */
85 public function willBeDropped();
86
87 /**
88 * Returns a `DatabaseTableColumn` object with the given name.
89 *
90 * @param string $name
91 * @return $this
92 */
93 public static function create($name);
94
95 /**
96 * Returns a `DatabaseTableColumn` object with the given name and data.
97 *
98 * @param string $name
99 * @param array $data data returned by `DatabaseEditor::getColumns()`
100 * @return $this
101 */
102 public static function createFromData($name, array $data);
103}