|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright 2018 Georg Ehrke <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Georg Ehrke <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU AGPL version 3 or any later version |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
13
|
|
|
* License, or (at your option) any later version. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OCA\DAV\Migration; |
|
26
|
|
|
|
|
27
|
|
|
use Doctrine\DBAL\Types\Type; |
|
28
|
|
|
use OCP\DB\ISchemaWrapper; |
|
29
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
30
|
|
|
use OCP\Migration\IOutput; |
|
31
|
|
|
|
|
32
|
|
|
class Version1006Date20180628111625 extends SimpleMigrationStep { |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param IOutput $output |
|
36
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37
|
|
|
* @param array $options |
|
38
|
|
|
* @return null|ISchemaWrapper |
|
39
|
|
|
*/ |
|
40
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
41
|
|
|
/** @var ISchemaWrapper $schema */ |
|
42
|
|
|
$schema = $schemaClosure(); |
|
43
|
|
|
|
|
44
|
|
|
if ($schema->hasTable('calendarchanges')) { |
|
45
|
|
|
$calendarChangesTable = $schema->getTable('calendarchanges'); |
|
46
|
|
|
$calendarChangesTable->addColumn('calendartype', Type::INTEGER, [ |
|
47
|
|
|
'notnull' => true, |
|
48
|
|
|
'default' => 0, |
|
49
|
|
|
]); |
|
50
|
|
|
|
|
51
|
|
|
if ($calendarChangesTable->hasIndex('calendarid_synctoken')) { |
|
52
|
|
|
$calendarChangesTable->dropIndex('calendarid_synctoken'); |
|
53
|
|
|
} |
|
54
|
|
|
$calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calendarid_calendartype_synctoken'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ($schema->hasTable('calendarobjects')) { |
|
58
|
|
|
$calendarObjectsTable = $schema->getTable('calendarobjects'); |
|
59
|
|
|
$calendarObjectsTable->addColumn('calendartype', Type::INTEGER, [ |
|
60
|
|
|
'notnull' => true, |
|
61
|
|
|
'default' => 0, |
|
62
|
|
|
]); |
|
63
|
|
|
|
|
64
|
|
|
if ($calendarObjectsTable->hasIndex('calobjects_index')) { |
|
65
|
|
|
$calendarObjectsTable->dropIndex('calobjects_index'); |
|
66
|
|
|
} |
|
67
|
|
|
$calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if ($schema->hasTable('calendarobjects_props')) { |
|
71
|
|
|
$calendarObjectsPropsTable = $schema->getTable('calendarobjects_props'); |
|
72
|
|
|
$calendarObjectsPropsTable->addColumn('calendartype', Type::INTEGER, [ |
|
73
|
|
|
'notnull' => true, |
|
74
|
|
|
'default' => 0, |
|
75
|
|
|
]); |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) { |
|
79
|
|
|
$calendarObjectsPropsTable->dropIndex('calendarobject_index'); |
|
80
|
|
|
} |
|
81
|
|
|
if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) { |
|
82
|
|
|
$calendarObjectsPropsTable->dropIndex('calendarobject_name_index'); |
|
83
|
|
|
} |
|
84
|
|
|
if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) { |
|
85
|
|
|
$calendarObjectsPropsTable->dropIndex('calendarobject_value_index'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index'); |
|
89
|
|
|
$calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index'); |
|
90
|
|
|
$calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index'); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if ($schema->hasTable('calendarsubscriptions')) { |
|
94
|
|
|
$calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions'); |
|
95
|
|
|
$calendarSubscriptionsTable->addColumn('synctoken', 'integer', [ |
|
96
|
|
|
'notnull' => true, |
|
97
|
|
|
'default' => 1, |
|
98
|
|
|
'length' => 10, |
|
99
|
|
|
'unsigned' => true, |
|
100
|
|
|
]); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $schema; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|