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
|
|
|
/** |
13
|
|
|
* Auto-generated migration step: Please modify to your needs! |
14
|
|
|
*/ |
15
|
|
|
class Version030702Date20200626072306 extends SimpleMigrationStep { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param IOutput $output |
19
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
20
|
|
|
* @param array $options |
21
|
|
|
*/ |
22
|
|
|
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param IOutput $output |
27
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
28
|
|
|
* @param array $options |
29
|
|
|
* @return null|ISchemaWrapper |
30
|
|
|
*/ |
31
|
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
32
|
|
|
/** @var ISchemaWrapper $schema */ |
33
|
|
|
$schema = $schemaClosure(); |
34
|
|
|
|
35
|
|
|
$table = $schema->getTable('richdocuments_wopi'); |
36
|
|
|
|
37
|
|
|
if (!$table->hasColumn('template_id')) { |
38
|
|
|
$table->addColumn('template_id', 'integer', [ |
39
|
|
|
'notnull' => false, |
40
|
|
|
'length' => 4, |
41
|
|
|
]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
View Code Duplication |
if (!$table->hasColumn('hide_download')) { |
|
|
|
|
45
|
|
|
$table->addColumn('hide_download', 'boolean', [ |
46
|
|
|
'notnull' => true, |
47
|
|
|
'default' => false, |
48
|
|
|
]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if (!$table->hasColumn('share')) { |
52
|
|
|
$table->addColumn('share', 'string', [ |
53
|
|
|
'notnull' => false, |
54
|
|
|
'length' => 64 |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
if (!$table->hasColumn('direct')) { |
|
|
|
|
59
|
|
|
$table->addColumn('direct', 'boolean', [ |
60
|
|
|
'notnull' => true, |
61
|
|
|
'default' => false, |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
View Code Duplication |
if (!$table->hasColumn('is_remote_token')) { |
|
|
|
|
65
|
|
|
$table->addColumn('is_remote_token', 'boolean', [ |
66
|
|
|
'notnull' => true, |
67
|
|
|
'default' => false, |
68
|
|
|
]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if (!$table->hasColumn('remote_server')) { |
72
|
|
|
$table->addColumn('remote_server', 'string', [ |
73
|
|
|
'notnull' => true, |
74
|
|
|
'default' => '', |
75
|
|
|
]); |
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
if (!$table->hasColumn('remote_server_token')) { |
79
|
|
|
$table->addColumn('remote_server_token', 'string', [ |
80
|
|
|
'notnull' => true, |
81
|
|
|
'length' => 32, |
82
|
|
|
'default' => '', |
83
|
|
|
]); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
return $schema; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param IOutput $output |
92
|
|
|
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
93
|
|
|
* @param array $options |
94
|
|
|
*/ |
95
|
|
|
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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.