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