-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathColumn.php
More file actions
160 lines (139 loc) · 3.88 KB
/
Column.php
File metadata and controls
160 lines (139 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
namespace Utopia\Migration\Resources\Database;
use Utopia\Migration\Resource;
use Utopia\Migration\Transfer;
abstract class Column extends Resource
{
public const TYPE_STRING = 'string';
public const TYPE_TEXT = 'text';
public const TYPE_VARCHAR = 'varchar';
public const TYPE_MEDIUMTEXT = 'mediumtext';
public const TYPE_LONGTEXT = 'longtext';
public const TYPE_INTEGER = 'integer';
public const TYPE_FLOAT = 'double';
public const TYPE_BOOLEAN = 'boolean';
public const TYPE_DATETIME = 'datetime';
public const TYPE_EMAIL = 'email';
public const TYPE_ENUM = 'enum';
public const TYPE_IP = 'ip';
public const TYPE_URL = 'url';
public const TYPE_RELATIONSHIP = 'relationship';
public const TYPE_POINT = 'point';
public const TYPE_LINE = 'linestring';
public const TYPE_POLYGON = 'polygon';
/**
* @param string $key
* @param Table $table
* @param int $size
* @param bool $required
* @param mixed|null $default
* @param bool $array
* @param bool $signed
* @param string $format
* @param array<string, mixed> $formatOptions
* @param array<string> $filters
* @param array<string, mixed> $options
* @param string $createdAt
* @param string $updatedAt
*/
public function __construct(
protected readonly string $key,
protected readonly Table $table,
protected readonly int $size = 0,
protected readonly bool $required = false,
protected readonly mixed $default = null,
protected readonly bool $array = false,
protected readonly bool $signed = false,
protected readonly string $format = '',
protected readonly array $formatOptions = [],
protected readonly array $filters = [],
protected array $options = [],
protected string $createdAt = '',
protected string $updatedAt = '',
) {
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return [
'key' => $this->key,
'table' => $this->table,
'type' => $this->getType(),
'size' => $this->size,
'required' => $this->required,
'default' => $this->default,
'array' => $this->array,
'signed' => $this->signed,
'format' => $this->format,
'formatOptions' => $this->formatOptions,
'filters' => $this->filters,
'options' => $this->options,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
public static function getName(): string
{
return Resource::TYPE_COLUMN;
}
abstract public function getType(): string;
public function getGroup(): string
{
return Transfer::GROUP_DATABASES;
}
public function getKey(): string
{
return $this->key;
}
public function getTable(): Table
{
return $this->table;
}
public function getSize(): int
{
return $this->size;
}
public function isRequired(): bool
{
return $this->required;
}
public function getDefault(): mixed
{
return $this->default;
}
public function isArray(): bool
{
return $this->array;
}
public function isSigned(): bool
{
return $this->signed;
}
public function getFormat(): string
{
return $this->format;
}
/**
* @return array<string, mixed>
*/
public function getFormatOptions(): array
{
return $this->formatOptions;
}
/**
* @return array<string>
*/
public function getFilters(): array
{
return $this->filters;
}
/**
* @return array<string, mixed>
*/
public function &getOptions(): array
{
return $this->options;
}
}