|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2017 René Gieling <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author René Gieling <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\Polls\Migration; |
|
25
|
|
|
|
|
26
|
|
|
// use Doctrine\DBAL\Exception\TableNotFoundException; |
|
27
|
|
|
// use Doctrine\DBAL\Platforms\PostgreSqlPlatform; |
|
28
|
|
|
use Doctrine\DBAL\Types\Type; |
|
|
|
|
|
|
29
|
|
|
use OCP\DB\ISchemaWrapper; |
|
30
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder; |
|
31
|
|
|
use OCP\IConfig; |
|
32
|
|
|
use OCP\IDBConnection; |
|
33
|
|
|
use OCP\Migration\SimpleMigrationStep; |
|
34
|
|
|
use OCP\Migration\IOutput; |
|
35
|
|
|
use OCP\Security\ISecureRandom; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Installation class for the polls app. |
|
39
|
|
|
* Initial db creation |
|
40
|
|
|
*/ |
|
41
|
|
|
class Version0010Date20191218203500 extends SimpleMigrationStep { |
|
42
|
|
|
|
|
43
|
|
|
/** @var IDBConnection */ |
|
44
|
|
|
protected $connection; |
|
45
|
|
|
|
|
46
|
|
|
/** @var IConfig */ |
|
47
|
|
|
protected $config; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param IDBConnection $connection |
|
51
|
|
|
* @param IConfig $config |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct(IDBConnection $connection, IConfig $config) { |
|
54
|
|
|
$this->connection = $connection; |
|
55
|
|
|
$this->config = $config; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param IOutput $output |
|
60
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
61
|
|
|
* @param array $options |
|
62
|
|
|
* @return null|ISchemaWrapper |
|
63
|
|
|
* @since 13.0.0 |
|
64
|
|
|
*/ |
|
65
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
66
|
|
|
/** @var ISchemaWrapper $schema */ |
|
67
|
|
|
$schema = $schemaClosure(); |
|
68
|
|
|
|
|
69
|
|
|
if ($schema->hasTable('polls_events')) { |
|
70
|
|
|
$table = $schema->getTable('polls_events'); |
|
71
|
|
|
if (!$table->hasColumn('expiration')) { |
|
72
|
|
|
$table->addColumn('expiration', Type::BOOLEAN, [ |
|
73
|
|
|
'notnull' => true, |
|
74
|
|
|
'default' => 0 |
|
75
|
|
|
]); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $schema; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param IOutput $output |
|
85
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
86
|
|
|
* @param array $options |
|
87
|
|
|
* @since 13.0.0 |
|
88
|
|
|
*/ |
|
89
|
|
|
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
90
|
|
|
/** @var ISchemaWrapper $schema */ |
|
91
|
|
|
$schema = $schemaClosure(); |
|
92
|
|
|
|
|
93
|
|
|
if ($schema->hasTable('polls_events')) { |
|
94
|
|
|
$this->setExpiration(); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Copy public tokens |
|
100
|
|
|
*/ |
|
101
|
|
|
protected function setExpiration() { |
|
102
|
|
|
|
|
103
|
|
|
$update = $this->connection->getQueryBuilder(); |
|
104
|
|
|
$update->update('polls_events') |
|
105
|
|
|
->set('expiration', $update->createNamedParameter(true)) |
|
106
|
|
|
->where('expire IS NOT NULL'); |
|
107
|
|
|
$result = $update->execute(); |
|
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths