1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace OCA\Richdocuments\Migration; |
6
|
|
|
|
7
|
|
|
use Closure; |
8
|
|
|
use OCP\DB\ISchemaWrapper; |
9
|
|
|
use OCP\Migration\SimpleMigrationStep; |
10
|
|
|
use OCP\Migration\IOutput; |
11
|
|
|
|
12
|
|
|
class Version30704Date20200626072306 extends SimpleMigrationStep { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @param IOutput $output |
16
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
17
|
|
|
* @param array $options |
18
|
|
|
* @return null|ISchemaWrapper |
19
|
|
|
*/ |
20
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
21
|
|
|
/** @var ISchemaWrapper $schema */ |
22
|
|
|
$schema = $schemaClosure(); |
23
|
|
|
|
24
|
|
|
$table = $schema->getTable('richdocuments_wopi'); |
25
|
|
|
|
26
|
|
|
if (!$table->hasColumn('template_id')) { |
27
|
|
|
$table->addColumn('template_id', 'integer', [ |
28
|
|
|
'notnull' => false, |
29
|
|
|
'length' => 4, |
30
|
|
|
]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
View Code Duplication |
if (!$table->hasColumn('hide_download')) { |
|
|
|
|
34
|
|
|
$table->addColumn('hide_download', 'boolean', [ |
35
|
|
|
'notnull' => true, |
36
|
|
|
'default' => false, |
37
|
|
|
]); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (!$table->hasColumn('share')) { |
41
|
|
|
$table->addColumn('share', 'string', [ |
42
|
|
|
'notnull' => false, |
43
|
|
|
'length' => 64 |
44
|
|
|
]); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
if (!$table->hasColumn('direct')) { |
|
|
|
|
48
|
|
|
$table->addColumn('direct', 'boolean', [ |
49
|
|
|
'notnull' => true, |
50
|
|
|
'default' => false, |
51
|
|
|
]); |
52
|
|
|
} |
53
|
|
View Code Duplication |
if (!$table->hasColumn('is_remote_token')) { |
|
|
|
|
54
|
|
|
$table->addColumn('is_remote_token', 'boolean', [ |
55
|
|
|
'notnull' => true, |
56
|
|
|
'default' => false, |
57
|
|
|
]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (!$table->hasColumn('remote_server')) { |
61
|
|
|
$table->addColumn('remote_server', 'string', [ |
62
|
|
|
'notnull' => true, |
63
|
|
|
'default' => '', |
64
|
|
|
]); |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
if (!$table->hasColumn('remote_server_token')) { |
68
|
|
|
$table->addColumn('remote_server_token', 'string', [ |
69
|
|
|
'notnull' => true, |
70
|
|
|
'length' => 32, |
71
|
|
|
'default' => '', |
72
|
|
|
]); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
return $schema; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.