1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
/** |
5
|
|
|
* @copyright Copyright (c) 2021 Joas Schilling <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @author Joas Schilling <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
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 |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace OC\Core\Migrations; |
26
|
|
|
|
27
|
|
|
use Closure; |
28
|
|
|
use Doctrine\DBAL\Types\Types; |
29
|
|
|
use OCP\DB\ISchemaWrapper; |
30
|
|
|
use OCP\Migration\IOutput; |
31
|
|
|
use OCP\Migration\SimpleMigrationStep; |
32
|
|
|
|
33
|
|
|
class Version21000Date20210309185126 extends SimpleMigrationStep { |
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): ?ISchemaWrapper { |
41
|
|
|
/** @var ISchemaWrapper $schema */ |
42
|
|
|
$schema = $schemaClosure(); |
43
|
|
|
|
44
|
|
|
if (!$schema->hasTable('known_users')) { |
45
|
|
|
$table = $schema->createTable('known_users'); |
46
|
|
|
|
47
|
|
|
// Auto increment id |
48
|
|
|
$table->addColumn('id', Types::BIGINT, [ |
49
|
|
|
'autoincrement' => true, |
50
|
|
|
'notnull' => true, |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
$table->addColumn('known_to', Types::STRING, [ |
54
|
|
|
'notnull' => true, |
55
|
|
|
'length' => 255, |
56
|
|
|
]); |
57
|
|
|
$table->addColumn('known_user', Types::STRING, [ |
58
|
|
|
'notnull' => true, |
59
|
|
|
'length' => 255, |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
$table->setPrimaryKey(['id']); |
63
|
|
|
$table->addIndex(['known_to'], 'ku_known_to'); |
64
|
|
|
return $schema; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return null; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|