|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace OCA\FaceRecognition\Migration; |
|
6
|
|
|
|
|
7
|
|
|
use Closure; |
|
8
|
|
|
use OCP\DB\ISchemaWrapper; |
|
9
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
10
|
|
|
use OCP\Migration\IOutput; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Auto-generated migration step: Please modify to your needs! |
|
14
|
|
|
*/ |
|
15
|
|
|
class Version000509Date20191203003814 extends SimpleMigrationStep { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @param IOutput $output |
|
19
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
20
|
|
|
* @param array $options |
|
21
|
|
|
* |
|
22
|
|
|
* @return void |
|
23
|
|
|
*/ |
|
24
|
|
|
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param IOutput $output |
|
29
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
30
|
|
|
* @param array $options |
|
31
|
|
|
* @return null|ISchemaWrapper |
|
32
|
|
|
*/ |
|
33
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
34
|
|
|
/** @var ISchemaWrapper $schema */ |
|
35
|
|
|
$schema = $schemaClosure(); |
|
36
|
|
|
|
|
37
|
|
|
if (!$schema->hasTable('facerecog_models')) { |
|
38
|
|
|
$table = $schema->createTable('facerecog_models'); |
|
39
|
|
|
$table->addColumn('id', 'integer', [ |
|
40
|
|
|
'autoincrement' => true, |
|
41
|
|
|
'notnull' => true, |
|
42
|
|
|
'length' => 4, |
|
43
|
|
|
]); |
|
44
|
|
|
$table->addColumn('name', 'string', [ |
|
45
|
|
|
'notnull' => true, |
|
46
|
|
|
'length' => 256, |
|
47
|
|
|
]); |
|
48
|
|
|
$table->addColumn('description', 'string', [ |
|
49
|
|
|
'notnull' => false, |
|
50
|
|
|
'length' => 1024, |
|
51
|
|
|
]); |
|
52
|
|
|
$table->setPrimaryKey(['id']); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
if (!$schema->hasTable('facerecog_persons')) { |
|
56
|
|
|
$table = $schema->createTable('facerecog_persons'); |
|
57
|
|
|
$table->addColumn('id', 'integer', [ |
|
58
|
|
|
'autoincrement' => true, |
|
59
|
|
|
'notnull' => true, |
|
60
|
|
|
'unsigned' => true, |
|
61
|
|
|
]); |
|
62
|
|
|
$table->addColumn('user', 'string', [ |
|
63
|
|
|
'notnull' => true, |
|
64
|
|
|
'length' => 64, |
|
65
|
|
|
]); |
|
66
|
|
|
$table->addColumn('name', 'string', [ |
|
67
|
|
|
'notnull' => true, |
|
68
|
|
|
'length' => 256, |
|
69
|
|
|
]); |
|
70
|
|
|
$table->addColumn('is_visible', 'boolean', [ |
|
71
|
|
|
'notnull' => false, |
|
72
|
|
|
'default' => true, |
|
73
|
|
|
]); |
|
74
|
|
|
$table->addColumn('is_valid', 'boolean', [ |
|
75
|
|
|
'notnull' => false, |
|
76
|
|
|
'default' => false, |
|
77
|
|
|
]); |
|
78
|
|
|
$table->addColumn('last_generation_time', 'datetime', [ |
|
79
|
|
|
'notnull' => false, |
|
80
|
|
|
]); |
|
81
|
|
|
$table->addColumn('linked_user', 'string', [ |
|
82
|
|
|
'notnull' => false, |
|
83
|
|
|
'length' => 64, |
|
84
|
|
|
]); |
|
85
|
|
|
$table->setPrimaryKey(['id']); |
|
86
|
|
|
$table->addIndex(['user'], 'persons_user_idx'); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if (!$schema->hasTable('facerecog_images')) { |
|
90
|
|
|
$table = $schema->createTable('facerecog_images'); |
|
91
|
|
|
$table->addColumn('id', 'integer', [ |
|
92
|
|
|
'autoincrement' => true, |
|
93
|
|
|
'notnull' => true, |
|
94
|
|
|
'length' => 4, |
|
95
|
|
|
]); |
|
96
|
|
|
$table->addColumn('user', 'string', [ |
|
97
|
|
|
'notnull' => true, |
|
98
|
|
|
'length' => 64, |
|
99
|
|
|
]); |
|
100
|
|
|
$table->addColumn('file', 'integer', [ |
|
101
|
|
|
'notnull' => true, |
|
102
|
|
|
'length' => 4, |
|
103
|
|
|
]); |
|
104
|
|
|
$table->addColumn('model', 'integer', [ |
|
105
|
|
|
'notnull' => true, |
|
106
|
|
|
'length' => 4, |
|
107
|
|
|
]); |
|
108
|
|
|
$table->addColumn('is_processed', 'boolean', [ |
|
109
|
|
|
'notnull' => false, |
|
110
|
|
|
'default' => false, |
|
111
|
|
|
]); |
|
112
|
|
|
$table->addColumn('error', 'string', [ |
|
113
|
|
|
'notnull' => false, |
|
114
|
|
|
'length' => 1024, |
|
115
|
|
|
]); |
|
116
|
|
|
$table->addColumn('last_processed_time', 'datetime', [ |
|
117
|
|
|
'notnull' => false, |
|
118
|
|
|
]); |
|
119
|
|
|
$table->addColumn('processing_duration', 'bigint', [ |
|
120
|
|
|
'notnull' => false, |
|
121
|
|
|
'length' => 8, |
|
122
|
|
|
]); |
|
123
|
|
|
$table->setPrimaryKey(['id']); |
|
124
|
|
|
$table->addIndex(['user'], 'images_user_idx'); |
|
125
|
|
|
$table->addIndex(['file'], 'images_file_idx'); |
|
126
|
|
|
$table->addIndex(['model'], 'images_model_idx'); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
if (!$schema->hasTable('facerecog_faces')) { |
|
130
|
|
|
$table = $schema->createTable('facerecog_faces'); |
|
131
|
|
|
$table->addColumn('id', 'integer', [ |
|
132
|
|
|
'autoincrement' => true, |
|
133
|
|
|
'notnull' => true, |
|
134
|
|
|
'length' => 4, |
|
135
|
|
|
]); |
|
136
|
|
|
$table->addColumn('image', 'integer', [ |
|
137
|
|
|
'notnull' => true, |
|
138
|
|
|
'length' => 4, |
|
139
|
|
|
]); |
|
140
|
|
|
$table->addColumn('person', 'integer', [ |
|
141
|
|
|
'notnull' => false, |
|
142
|
|
|
'length' => 4, |
|
143
|
|
|
]); |
|
144
|
|
|
$table->addColumn('x', 'integer', [ |
|
145
|
|
|
'notnull' => true, |
|
146
|
|
|
'length' => 4, |
|
147
|
|
|
]); |
|
148
|
|
|
$table->addColumn('y', 'integer', [ |
|
149
|
|
|
'notnull' => true, |
|
150
|
|
|
'length' => 4, |
|
151
|
|
|
]); |
|
152
|
|
|
$table->addColumn('width', 'integer', [ |
|
153
|
|
|
'notnull' => true, |
|
154
|
|
|
'length' => 4, |
|
155
|
|
|
]); |
|
156
|
|
|
$table->addColumn('height', 'integer', [ |
|
157
|
|
|
'notnull' => true, |
|
158
|
|
|
'length' => 4, |
|
159
|
|
|
]); |
|
160
|
|
|
$table->addColumn('is_groupable', 'boolean', [ |
|
161
|
|
|
'notnull' => false, |
|
162
|
|
|
'default' => true, |
|
163
|
|
|
]); |
|
164
|
|
|
$table->addColumn('confidence', 'float', [ |
|
165
|
|
|
'notnull' => true, |
|
166
|
|
|
'length' => 4, |
|
167
|
|
|
]); |
|
168
|
|
|
$table->addColumn('landmarks', 'json', [ |
|
169
|
|
|
'notnull' => true, |
|
170
|
|
|
]); |
|
171
|
|
|
$table->addColumn('descriptor', 'json', [ |
|
172
|
|
|
'notnull' => true, |
|
173
|
|
|
]); |
|
174
|
|
|
$table->addColumn('creation_time', 'datetime', [ |
|
175
|
|
|
'notnull' => true, |
|
176
|
|
|
]); |
|
177
|
|
|
$table->setPrimaryKey(['id']); |
|
178
|
|
|
$table->addIndex(['image'], 'faces_image_idx'); |
|
179
|
|
|
$table->addIndex(['person'], 'faces_person_idx'); |
|
180
|
|
|
} |
|
181
|
|
|
return $schema; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @param IOutput $output |
|
186
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
187
|
|
|
* @param array $options |
|
188
|
|
|
* |
|
189
|
|
|
* @return void |
|
190
|
|
|
*/ |
|
191
|
|
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|