1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright Copyright (c) 2020 Joas Schilling <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @author Côme Chilliet <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @license GNU AGPL version 3 or any later version |
11
|
|
|
* |
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
15
|
|
|
* License, or (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, |
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
* GNU Affero General Public License for more details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
24
|
|
|
* |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace OCA\User_LDAP\Migration; |
28
|
|
|
|
29
|
|
|
use Closure; |
30
|
|
|
use OCP\DB\ISchemaWrapper; |
31
|
|
|
use OCP\Migration\IOutput; |
32
|
|
|
|
33
|
|
|
class Version1130Date20220110154717 extends GroupMappingMigration { |
34
|
|
|
public function getName() { |
35
|
|
|
return 'Copy ldap_group_mapping data to backup table if needed'; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param IOutput $output |
40
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
41
|
|
|
* @param array $options |
42
|
|
|
* @since 13.0.0 |
43
|
|
|
*/ |
44
|
|
|
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
45
|
|
|
/** @var ISchemaWrapper $schema */ |
46
|
|
|
$schema = $schemaClosure(); |
47
|
|
|
|
48
|
|
|
if (!$schema->hasTable('ldap_group_mapping_backup')) { |
49
|
|
|
// Backup table does not exist |
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$output->startProgress(); |
54
|
|
|
$this->copyGroupMappingData('ldap_group_mapping', 'ldap_group_mapping_backup'); |
55
|
|
|
$output->finishProgress(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param IOutput $output |
60
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
61
|
|
|
* @param array $options |
62
|
|
|
* @return null|ISchemaWrapper |
63
|
|
|
*/ |
64
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
65
|
|
|
/** @var ISchemaWrapper $schema */ |
66
|
|
|
$schema = $schemaClosure(); |
67
|
|
|
|
68
|
|
|
if (!$schema->hasTable('ldap_group_mapping_backup')) { |
69
|
|
|
// Backup table does not exist |
70
|
|
|
return null; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$schema->dropTable('ldap_group_mapping'); |
74
|
|
|
|
75
|
|
|
return $schema; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|