|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright 2017 Georg Ehrke <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Georg Ehrke <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
namespace OCA\DAV\Migration; |
|
24
|
|
|
|
|
25
|
|
|
use Doctrine\DBAL\Types\Type; |
|
26
|
|
|
use OCP\DB\ISchemaWrapper; |
|
27
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
28
|
|
|
use OCP\Migration\IOutput; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Auto-generated migration step: Please modify to your needs! |
|
32
|
|
|
*/ |
|
33
|
|
|
class Version1005Date20180530124431 extends SimpleMigrationStep { |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param IOutput $output |
|
37
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38
|
|
|
* @param array $options |
|
39
|
|
|
* @return null|ISchemaWrapper |
|
40
|
|
|
* @since 13.0.0 |
|
41
|
|
|
*/ |
|
42
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
43
|
|
|
/** @var ISchemaWrapper $schema */ |
|
44
|
|
|
$schema = $schemaClosure(); |
|
45
|
|
|
|
|
46
|
|
|
$types = ['resources', 'rooms']; |
|
47
|
|
|
foreach($types as $type) { |
|
48
|
|
|
if (!$schema->hasTable('calendar_' . $type . '_cache')) { |
|
49
|
|
|
$table = $schema->createTable('calendar_' . $type . '_cache'); |
|
50
|
|
|
|
|
51
|
|
|
$table->addColumn('id', Type::BIGINT, [ |
|
52
|
|
|
'autoincrement' => true, |
|
53
|
|
|
'notnull' => true, |
|
54
|
|
|
'length' => 11, |
|
55
|
|
|
'unsigned' => true, |
|
56
|
|
|
]); |
|
57
|
|
|
$table->addColumn('backend_id', Type::STRING, [ |
|
58
|
|
|
'notnull' => false, |
|
59
|
|
|
'length' => 64, |
|
60
|
|
|
]); |
|
61
|
|
|
$table->addColumn('resource_id', Type::STRING, [ |
|
62
|
|
|
'notnull' => false, |
|
63
|
|
|
'length' => 64, |
|
64
|
|
|
]); |
|
65
|
|
|
$table->addColumn('email', Type::STRING, [ |
|
66
|
|
|
'notnull' => false, |
|
67
|
|
|
'length' => 255, |
|
68
|
|
|
]); |
|
69
|
|
|
$table->addColumn('displayname', Type::STRING, [ |
|
70
|
|
|
'notnull' => false, |
|
71
|
|
|
'length' => 255, |
|
72
|
|
|
]); |
|
73
|
|
|
$table->addColumn('group_restrictions', Type::STRING, [ |
|
74
|
|
|
'notnull' => false, |
|
75
|
|
|
'length' => 4000, |
|
76
|
|
|
]); |
|
77
|
|
|
|
|
78
|
|
|
$table->setPrimaryKey(['id'], 'calendar_' . $type . '_cache_id_idx'); |
|
79
|
|
|
$table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_cache_backendresource_idx'); |
|
80
|
|
|
$table->addIndex(['email'], 'calendar_' . $type . '_cache_email_idx'); |
|
81
|
|
|
$table->addIndex(['displayname'], 'calendar_' . $type . '_cache_displayname_idx'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return $schema; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|