1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2017 Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Joas Schilling <[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
|
|
|
|
24
|
|
|
namespace OCA\Activity\Migration; |
25
|
|
|
|
26
|
|
|
use Doctrine\DBAL\Types\Type; |
27
|
|
|
use OCP\DB\ISchemaWrapper; |
28
|
|
|
use OCP\Migration\SimpleMigrationStep; |
29
|
|
|
use OCP\Migration\IOutput; |
30
|
|
|
|
31
|
|
|
class Version2006Date20170808154933 extends SimpleMigrationStep { |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param IOutput $output |
35
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
36
|
|
|
* @param array $options |
37
|
|
|
* @return null|ISchemaWrapper |
38
|
|
|
* @since 13.0.0 |
39
|
|
|
*/ |
40
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
41
|
|
|
/** @var ISchemaWrapper $schema */ |
42
|
|
|
$schema = $schemaClosure(); |
43
|
|
|
|
44
|
|
|
if (!$schema->hasTable('activity')) { |
45
|
|
|
$table = $schema->createTable('activity'); |
46
|
|
|
$table->addColumn('activity_id', Type::BIGINT, [ |
47
|
|
|
'autoincrement' => true, |
48
|
|
|
'notnull' => true, |
49
|
|
|
'length' => 20, |
50
|
|
|
]); |
51
|
|
|
$table->addColumn('timestamp', 'integer', [ |
52
|
|
|
'notnull' => true, |
53
|
|
|
'length' => 4, |
54
|
|
|
'default' => 0, |
55
|
|
|
]); |
56
|
|
|
$table->addColumn('priority', 'integer', [ |
57
|
|
|
'notnull' => true, |
58
|
|
|
'length' => 4, |
59
|
|
|
'default' => 0, |
60
|
|
|
]); |
61
|
|
|
$table->addColumn('type', 'string', [ |
62
|
|
|
'notnull' => false, |
63
|
|
|
'length' => 255, |
64
|
|
|
]); |
65
|
|
|
$table->addColumn('user', 'string', [ |
66
|
|
|
'notnull' => false, |
67
|
|
|
'length' => 64, |
68
|
|
|
]); |
69
|
|
|
$table->addColumn('affecteduser', 'string', [ |
70
|
|
|
'notnull' => true, |
71
|
|
|
'length' => 64, |
72
|
|
|
]); |
73
|
|
|
$table->addColumn('app', 'string', [ |
74
|
|
|
'notnull' => true, |
75
|
|
|
'length' => 32, |
76
|
|
|
]); |
77
|
|
|
$table->addColumn('subject', 'string', [ |
78
|
|
|
'notnull' => true, |
79
|
|
|
'length' => 255, |
80
|
|
|
]); |
81
|
|
|
$table->addColumn('subjectparams', 'text', [ |
82
|
|
|
'notnull' => true, |
83
|
|
|
]); |
84
|
|
|
$table->addColumn('message', 'string', [ |
85
|
|
|
'notnull' => false, |
86
|
|
|
'length' => 255, |
87
|
|
|
]); |
88
|
|
|
$table->addColumn('messageparams', 'text', [ |
89
|
|
|
'notnull' => false, |
90
|
|
|
]); |
91
|
|
|
$table->addColumn('file', 'string', [ |
92
|
|
|
'notnull' => false, |
93
|
|
|
'length' => 4000, |
94
|
|
|
]); |
95
|
|
|
$table->addColumn('link', 'string', [ |
96
|
|
|
'notnull' => false, |
97
|
|
|
'length' => 4000, |
98
|
|
|
]); |
99
|
|
|
$table->addColumn('object_type', 'string', [ |
100
|
|
|
'notnull' => false, |
101
|
|
|
'length' => 255, |
102
|
|
|
]); |
103
|
|
|
$table->addColumn('object_id', Type::BIGINT, [ |
104
|
|
|
'notnull' => true, |
105
|
|
|
'length' => 20, |
106
|
|
|
'default' => 0, |
107
|
|
|
]); |
108
|
|
|
$table->setPrimaryKey(['activity_id']); |
109
|
|
|
$table->addIndex(['timestamp'], 'activity_time'); |
110
|
|
|
$table->addIndex(['affecteduser', 'timestamp'], 'activity_user_time'); |
111
|
|
|
$table->addIndex(['affecteduser', 'user', 'timestamp'], 'activity_filter_by'); |
112
|
|
|
// FIXME Fixed install, see Version2006Date20170808155040: $table->addIndex(['affecteduser', 'app', 'timestamp'], 'activity_filter_app'); |
113
|
|
|
$table->addIndex(['affecteduser', 'type', 'app', 'timestamp'], 'activity_filter'); |
114
|
|
|
$table->addIndex(['object_type', 'object_id'], 'activity_object'); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
if (!$schema->hasTable('activity_mq')) { |
118
|
|
|
$table = $schema->createTable('activity_mq'); |
119
|
|
|
$table->addColumn('mail_id', Type::BIGINT, [ |
120
|
|
|
'autoincrement' => true, |
121
|
|
|
'notnull' => true, |
122
|
|
|
'length' => 20, |
123
|
|
|
]); |
124
|
|
|
$table->addColumn('amq_timestamp', 'integer', [ |
125
|
|
|
'notnull' => true, |
126
|
|
|
'length' => 4, |
127
|
|
|
'default' => 0, |
128
|
|
|
]); |
129
|
|
|
$table->addColumn('amq_latest_send', 'integer', [ |
130
|
|
|
'notnull' => true, |
131
|
|
|
'length' => 4, |
132
|
|
|
'default' => 0, |
133
|
|
|
]); |
134
|
|
|
$table->addColumn('amq_type', 'string', [ |
135
|
|
|
'notnull' => true, |
136
|
|
|
'length' => 255, |
137
|
|
|
]); |
138
|
|
|
$table->addColumn('amq_affecteduser', 'string', [ |
139
|
|
|
'notnull' => true, |
140
|
|
|
'length' => 64, |
141
|
|
|
]); |
142
|
|
|
$table->addColumn('amq_appid', 'string', [ |
143
|
|
|
'notnull' => true, |
144
|
|
|
'length' => 255, |
145
|
|
|
]); |
146
|
|
|
$table->addColumn('amq_subject', 'string', [ |
147
|
|
|
'notnull' => true, |
148
|
|
|
'length' => 255, |
149
|
|
|
]); |
150
|
|
|
$table->addColumn('amq_subjectparams', 'string', [ |
151
|
|
|
'notnull' => true, |
152
|
|
|
'length' => 4000, |
153
|
|
|
]); |
154
|
|
|
$table->setPrimaryKey(['mail_id']); |
155
|
|
|
$table->addIndex(['amq_affecteduser'], 'amp_user'); |
156
|
|
|
$table->addIndex(['amq_latest_send'], 'amp_latest_send_time'); |
157
|
|
|
$table->addIndex(['amq_timestamp'], 'amp_timestamp_time'); |
158
|
|
|
} |
159
|
|
|
return $schema; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
} |
163
|
|
|
|