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 Version0022Date20220613112211 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_circle')) { |
94
|
|
|
$table = $schema->getTable('circles_circle'); |
95
|
|
|
if (!$table->hasColumn('sanitized_name')) { |
96
|
|
|
$table->addColumn( |
97
|
|
|
'sanitized_name', 'string', [ |
98
|
|
|
'notnull' => false, |
99
|
|
|
'default' => '', |
100
|
|
|
'length' => 127 |
101
|
|
|
] |
102
|
|
|
); |
103
|
|
|
|
104
|
|
|
$table->addIndex(['sanitized_name']); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
if ($schema->hasTable('circles_membership')) { |
110
|
|
|
$table = $schema->getTable('circles_membership'); |
111
|
|
|
$table->changeColumn( |
112
|
|
|
'circle_id', [ |
113
|
|
|
'notnull' => true, |
114
|
|
|
'length' => 31, |
115
|
|
|
] |
116
|
|
|
); |
117
|
|
|
$table->changeColumn( |
118
|
|
|
'single_id', [ |
119
|
|
|
'notnull' => true, |
120
|
|
|
'length' => 31, |
121
|
|
|
] |
122
|
|
|
); |
123
|
|
|
$table->changeColumn( |
124
|
|
|
'inheritance_first', [ |
125
|
|
|
'notnull' => true, |
126
|
|
|
'length' => 31, |
127
|
|
|
] |
128
|
|
|
); |
129
|
|
|
$table->changeColumn( |
130
|
|
|
'inheritance_last', [ |
131
|
|
|
'notnull' => true, |
132
|
|
|
'length' => 31, |
133
|
|
|
] |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
if ($schema->hasTable('circles_mount')) { |
139
|
|
|
$table = $schema->getTable('circles_mount'); |
140
|
|
|
$table->changeColumn( |
141
|
|
|
'mount_id', [ |
142
|
|
|
'notnull' => true, |
143
|
|
|
'length' => 31, |
144
|
|
|
] |
145
|
|
|
); |
146
|
|
|
$table->changeColumn( |
147
|
|
|
'circle_id', [ |
148
|
|
|
'notnull' => true, |
149
|
|
|
'length' => 31, |
150
|
|
|
] |
151
|
|
|
); |
152
|
|
|
$table->changeColumn( |
153
|
|
|
'single_id', [ |
154
|
|
|
'notnull' => true, |
155
|
|
|
'length' => 31, |
156
|
|
|
] |
157
|
|
|
); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
if ($schema->hasTable('circles_mountpoint')) { |
162
|
|
|
$table = $schema->getTable('circles_mountpoint'); |
163
|
|
|
$table->changeColumn( |
164
|
|
|
'mount_id', [ |
165
|
|
|
'notnull' => true, |
166
|
|
|
'length' => 31, |
167
|
|
|
] |
168
|
|
|
); |
169
|
|
|
$table->changeColumn( |
170
|
|
|
'single_id', [ |
171
|
|
|
'notnull' => true, |
172
|
|
|
'length' => 31, |
173
|
|
|
] |
174
|
|
|
); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
if ($schema->hasTable('circles_share_lock')) { |
179
|
|
|
$table = $schema->getTable('circles_share_lock'); |
180
|
|
|
$table->changeColumn( |
181
|
|
|
'item_id', [ |
182
|
|
|
'notnull' => true, |
183
|
|
|
'length' => 31, |
184
|
|
|
] |
185
|
|
|
); |
186
|
|
|
$table->changeColumn( |
187
|
|
|
'circle_id', [ |
188
|
|
|
'notnull' => true, |
189
|
|
|
'length' => 31, |
190
|
|
|
] |
191
|
|
|
); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
|
195
|
|
|
return $schema; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
|