|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Circles - Bring cloud-users closer together. |
|
8
|
|
|
* |
|
9
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
10
|
|
|
* later. See the COPYING file. |
|
11
|
|
|
* |
|
12
|
|
|
* @author Maxence Lange <[email protected]> |
|
13
|
|
|
* @copyright 2021 |
|
14
|
|
|
* @license GNU AGPL version 3 or any later version |
|
15
|
|
|
* |
|
16
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
17
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
18
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
19
|
|
|
* License, or (at your option) any later version. |
|
20
|
|
|
* |
|
21
|
|
|
* This program is distributed in the hope that it will be useful, |
|
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24
|
|
|
* GNU Affero General Public License for more details. |
|
25
|
|
|
* |
|
26
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
namespace OCA\Circles\Migration; |
|
33
|
|
|
|
|
34
|
|
|
use Closure; |
|
35
|
|
|
use Doctrine\DBAL\Schema\SchemaException; |
|
36
|
|
|
use OCP\DB\ISchemaWrapper; |
|
37
|
|
|
use OCP\IDBConnection; |
|
38
|
|
|
use OCP\Migration\IOutput; |
|
39
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class Version0022Date20220526113601 |
|
44
|
|
|
* |
|
45
|
|
|
* @package OCA\Circles\Migration |
|
46
|
|
|
*/ |
|
47
|
|
|
class Version0022Date20220623224231 extends SimpleMigrationStep { |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param IDBConnection $connection |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct(IDBConnection $connection) { |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param IOutput $output |
|
59
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
60
|
|
|
* @param array $options |
|
61
|
|
|
* |
|
62
|
|
|
* @return null|ISchemaWrapper |
|
63
|
|
|
* @throws SchemaException |
|
64
|
|
|
*/ |
|
65
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
66
|
|
|
/** @var ISchemaWrapper $schema */ |
|
67
|
|
|
$schema = $schemaClosure(); |
|
68
|
|
|
|
|
69
|
|
|
if ($schema->hasTable('circles_event')) { |
|
70
|
|
|
$table = $schema->getTable('circles_event'); |
|
71
|
|
|
if (!$table->hasColumn('updated')) { |
|
72
|
|
|
$table->addColumn( |
|
73
|
|
|
'updated', 'datetime', [ |
|
74
|
|
|
'notnull' => false, |
|
75
|
|
|
] |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
if ($schema->hasTable('circles_member')) { |
|
81
|
|
|
$table = $schema->getTable('circles_member'); |
|
82
|
|
|
if (!$table->hasColumn('invited_by')) { |
|
83
|
|
|
$table->addColumn( |
|
84
|
|
|
'invited_by', 'string', [ |
|
85
|
|
|
'notnull' => false, |
|
86
|
|
|
'default' => '', |
|
87
|
|
|
'length' => 31, |
|
88
|
|
|
] |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if ($schema->hasTable('circles_membership')) { |
|
94
|
|
|
$table = $schema->getTable('circles_membership'); |
|
95
|
|
|
if (!$table->hasColumn('config')) { |
|
96
|
|
|
$table->addColumn( |
|
97
|
|
|
'config', 'integer', [ |
|
98
|
|
|
'notnull' => false, |
|
99
|
|
|
'length' => 11, |
|
100
|
|
|
'unsigned' => true |
|
101
|
|
|
] |
|
102
|
|
|
); |
|
103
|
|
|
$table->addIndex(['single_id', 'config']); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
if ($schema->hasTable('circles_circle')) { |
|
109
|
|
|
$table = $schema->getTable('circles_circle'); |
|
110
|
|
|
if (!$table->hasColumn('sanitized_name')) { |
|
111
|
|
|
$table->addColumn( |
|
112
|
|
|
'sanitized_name', 'string', [ |
|
113
|
|
|
'notnull' => false, |
|
114
|
|
|
'default' => '', |
|
115
|
|
|
'length' => 127 |
|
116
|
|
|
] |
|
117
|
|
|
); |
|
118
|
|
|
|
|
119
|
|
|
$table->addIndex(['sanitized_name']); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
if ($schema->hasTable('circles_membership')) { |
|
125
|
|
|
$table = $schema->getTable('circles_membership'); |
|
126
|
|
|
$table->changeColumn( |
|
127
|
|
|
'circle_id', [ |
|
128
|
|
|
'notnull' => true, |
|
129
|
|
|
'length' => 31, |
|
130
|
|
|
] |
|
131
|
|
|
); |
|
132
|
|
|
$table->changeColumn( |
|
133
|
|
|
'single_id', [ |
|
134
|
|
|
'notnull' => true, |
|
135
|
|
|
'length' => 31, |
|
136
|
|
|
] |
|
137
|
|
|
); |
|
138
|
|
|
$table->changeColumn( |
|
139
|
|
|
'inheritance_first', [ |
|
140
|
|
|
'notnull' => true, |
|
141
|
|
|
'length' => 31, |
|
142
|
|
|
] |
|
143
|
|
|
); |
|
144
|
|
|
$table->changeColumn( |
|
145
|
|
|
'inheritance_last', [ |
|
146
|
|
|
'notnull' => true, |
|
147
|
|
|
'length' => 31, |
|
148
|
|
|
] |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
|
|
153
|
|
|
if ($schema->hasTable('circles_mount')) { |
|
154
|
|
|
$table = $schema->getTable('circles_mount'); |
|
155
|
|
|
$table->changeColumn( |
|
156
|
|
|
'mount_id', [ |
|
157
|
|
|
'notnull' => true, |
|
158
|
|
|
'length' => 31, |
|
159
|
|
|
] |
|
160
|
|
|
); |
|
161
|
|
|
$table->changeColumn( |
|
162
|
|
|
'circle_id', [ |
|
163
|
|
|
'notnull' => true, |
|
164
|
|
|
'length' => 31, |
|
165
|
|
|
] |
|
166
|
|
|
); |
|
167
|
|
|
$table->changeColumn( |
|
168
|
|
|
'single_id', [ |
|
169
|
|
|
'notnull' => true, |
|
170
|
|
|
'length' => 31, |
|
171
|
|
|
] |
|
172
|
|
|
); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
if ($schema->hasTable('circles_mountpoint')) { |
|
177
|
|
|
$table = $schema->getTable('circles_mountpoint'); |
|
178
|
|
|
$table->changeColumn( |
|
179
|
|
|
'mount_id', [ |
|
180
|
|
|
'notnull' => true, |
|
181
|
|
|
'length' => 31, |
|
182
|
|
|
] |
|
183
|
|
|
); |
|
184
|
|
|
$table->changeColumn( |
|
185
|
|
|
'single_id', [ |
|
186
|
|
|
'notnull' => true, |
|
187
|
|
|
'length' => 31, |
|
188
|
|
|
] |
|
189
|
|
|
); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
if ($schema->hasTable('circles_share_lock')) { |
|
194
|
|
|
$table = $schema->getTable('circles_share_lock'); |
|
195
|
|
|
$table->changeColumn( |
|
196
|
|
|
'item_id', [ |
|
197
|
|
|
'notnull' => true, |
|
198
|
|
|
'length' => 31, |
|
199
|
|
|
] |
|
200
|
|
|
); |
|
201
|
|
|
$table->changeColumn( |
|
202
|
|
|
'circle_id', [ |
|
203
|
|
|
'notnull' => true, |
|
204
|
|
|
'length' => 31, |
|
205
|
|
|
] |
|
206
|
|
|
); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
|
|
210
|
|
|
return $schema; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
|