|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright Copyright (c) 2020, Georg Ehrke |
|
7
|
|
|
* |
|
8
|
|
|
* @author Georg Ehrke <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license AGPL-3.0 |
|
11
|
|
|
* |
|
12
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
14
|
|
|
* as published by the Free Software Foundation. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace OCA\UserStatus\Migration; |
|
27
|
|
|
|
|
28
|
|
|
use Doctrine\DBAL\Types\Types; |
|
29
|
|
|
use OCP\DB\ISchemaWrapper; |
|
30
|
|
|
use OCP\Migration\IOutput; |
|
31
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Class Version0001Date20200602134824 |
|
35
|
|
|
* |
|
36
|
|
|
* @package OCA\UserStatus\Migration |
|
37
|
|
|
*/ |
|
38
|
|
|
class Version0001Date20200602134824 extends SimpleMigrationStep { |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param IOutput $output |
|
42
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43
|
|
|
* @param array $options |
|
44
|
|
|
* @return null|ISchemaWrapper |
|
45
|
|
|
* @since 20.0.0 |
|
46
|
|
|
*/ |
|
47
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
48
|
|
|
/** @var ISchemaWrapper $schema */ |
|
49
|
|
|
$schema = $schemaClosure(); |
|
50
|
|
|
|
|
51
|
|
|
$statusTable = $schema->createTable('user_status'); |
|
52
|
|
|
$statusTable->addColumn('id', Types::BIGINT, [ |
|
53
|
|
|
'autoincrement' => true, |
|
54
|
|
|
'notnull' => true, |
|
55
|
|
|
'length' => 20, |
|
56
|
|
|
'unsigned' => true, |
|
57
|
|
|
]); |
|
58
|
|
|
$statusTable->addColumn('user_id', Types::STRING, [ |
|
59
|
|
|
'notnull' => true, |
|
60
|
|
|
'length' => 255, |
|
61
|
|
|
]); |
|
62
|
|
|
$statusTable->addColumn('status', Types::STRING, [ |
|
63
|
|
|
'notnull' => true, |
|
64
|
|
|
'length' => 255, |
|
65
|
|
|
]); |
|
66
|
|
|
$statusTable->addColumn('status_timestamp', Types::INTEGER, [ |
|
67
|
|
|
'notnull' => true, |
|
68
|
|
|
'length' => 11, |
|
69
|
|
|
'unsigned' => true, |
|
70
|
|
|
]); |
|
71
|
|
|
$statusTable->addColumn('is_user_defined', Types::BOOLEAN, [ |
|
72
|
|
|
'notnull' => true, |
|
73
|
|
|
]); |
|
74
|
|
|
$statusTable->addColumn('message_id', Types::STRING, [ |
|
75
|
|
|
'notnull' => false, |
|
76
|
|
|
'length' => 255, |
|
77
|
|
|
]); |
|
78
|
|
|
$statusTable->addColumn('custom_icon', Types::STRING, [ |
|
79
|
|
|
'notnull' => false, |
|
80
|
|
|
'length' => 255, |
|
81
|
|
|
]); |
|
82
|
|
|
$statusTable->addColumn('custom_message', Types::TEXT, [ |
|
83
|
|
|
'notnull' => false, |
|
84
|
|
|
]); |
|
85
|
|
|
$statusTable->addColumn('clear_at', Types::INTEGER, [ |
|
86
|
|
|
'notnull' => false, |
|
87
|
|
|
'length' => 11, |
|
88
|
|
|
'unsigned' => true, |
|
89
|
|
|
]); |
|
90
|
|
|
|
|
91
|
|
|
$statusTable->setPrimaryKey(['id']); |
|
92
|
|
|
$statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix'); |
|
93
|
|
|
$statusTable->addIndex(['clear_at'], 'user_status_clr_ix'); |
|
94
|
|
|
|
|
95
|
|
|
return $schema; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|