1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* @copyright Copyright (c) 2019 Julius Härtl <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @author Julius Härtl <[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
|
|
|
|
26
|
|
|
namespace OC\Core\Migrations; |
27
|
|
|
|
28
|
|
|
use Closure; |
29
|
|
|
use Doctrine\DBAL\Types\Type; |
30
|
|
|
use OCP\DB\ISchemaWrapper; |
31
|
|
|
use OCP\IDBConnection; |
32
|
|
|
use OCP\Migration\SimpleMigrationStep; |
33
|
|
|
use OCP\Migration\IOutput; |
34
|
|
|
|
35
|
|
|
class Version18000Date20191014105105 extends SimpleMigrationStep { |
36
|
|
|
|
37
|
|
|
/** @var IDBConnection */ |
38
|
|
|
protected $connection; |
39
|
|
|
|
40
|
|
|
public function __construct(IDBConnection $connection) { |
41
|
|
|
$this->connection = $connection; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param IOutput $output |
46
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
47
|
|
|
* @param array $options |
48
|
|
|
* @return null|ISchemaWrapper |
49
|
|
|
*/ |
50
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
51
|
|
|
/** @var ISchemaWrapper $schema */ |
52
|
|
|
$schema = $schemaClosure(); |
53
|
|
|
$table = $schema->createTable('direct_edit'); |
54
|
|
|
|
55
|
|
|
$table->addColumn('id', Type::BIGINT, [ |
56
|
|
|
'autoincrement' => true, |
57
|
|
|
'notnull' => true, |
58
|
|
|
]); |
59
|
|
|
$table->addColumn('editor_id', Type::STRING, [ |
60
|
|
|
'notnull' => true, |
61
|
|
|
'length' => 64, |
62
|
|
|
]); |
63
|
|
|
$table->addColumn('token', Type::STRING, [ |
64
|
|
|
'notnull' => true, |
65
|
|
|
'length' => 64, |
66
|
|
|
]); |
67
|
|
|
$table->addColumn('file_id', Type::BIGINT, [ |
68
|
|
|
'notnull' => true, |
69
|
|
|
]); |
70
|
|
|
$table->addColumn('user_id', Type::STRING, [ |
71
|
|
|
'notnull' => false, |
72
|
|
|
'length' => 64, |
73
|
|
|
]); |
74
|
|
|
$table->addColumn('share_id', Type::BIGINT, [ |
75
|
|
|
'notnull' => false |
76
|
|
|
]); |
77
|
|
|
$table->addColumn('timestamp', Type::BIGINT, [ |
78
|
|
|
'notnull' => true, |
79
|
|
|
'length' => 20, |
80
|
|
|
'unsigned' => true, |
81
|
|
|
]); |
82
|
|
|
$table->addColumn('accessed', Type::BOOLEAN, [ |
83
|
|
|
'notnull' => true, |
84
|
|
|
'default' => false |
85
|
|
|
]); |
86
|
|
|
|
87
|
|
|
$table->setPrimaryKey(['id']); |
88
|
|
|
$table->addIndex(['token']); |
89
|
|
|
|
90
|
|
|
return $schema; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|