Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
Version000303Date20200201171814 | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
preSchemaChange | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
changeSchema | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
postSchemaChange | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace OCA\Cospend\Migration; |
6 | |
7 | use Closure; |
8 | use OCP\DB\ISchemaWrapper; |
9 | use OCP\Migration\SimpleMigrationStep; |
10 | use OCP\Migration\IOutput; |
11 | use OCP\DB\QueryBuilder\IQueryBuilder; |
12 | use OCP\IDBConnection; |
13 | |
14 | /** |
15 | * Auto-generated migration step: Please modify to your needs! |
16 | */ |
17 | class Version000303Date20200201171814 extends SimpleMigrationStep { |
18 | |
19 | /** @var IDBConnection */ |
20 | private $connection; |
21 | |
22 | /** |
23 | * @param IDBConnection $connection |
24 | */ |
25 | public function __construct(IDBConnection $connection) { |
26 | $this->connection = $connection; |
27 | } |
28 | |
29 | /** |
30 | * @param IOutput $output |
31 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
32 | * @param array $options |
33 | */ |
34 | public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
35 | } |
36 | |
37 | /** |
38 | * @param IOutput $output |
39 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
40 | * @param array $options |
41 | * @return null|ISchemaWrapper |
42 | */ |
43 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
44 | /** @var ISchemaWrapper $schema */ |
45 | $schema = $schemaClosure(); |
46 | |
47 | if ($schema->hasTable('cospend_shares')) { |
48 | $table = $schema->getTable('cospend_shares'); |
49 | $table->addColumn('type', 'string', [ |
50 | 'notnull' => true, |
51 | 'length' => 1, |
52 | 'default' => 'u' |
53 | ]); |
54 | } |
55 | |
56 | return $schema; |
57 | } |
58 | |
59 | /** |
60 | * @param IOutput $output |
61 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
62 | * @param array $options |
63 | */ |
64 | public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
65 | $qb = $this->connection->getQueryBuilder(); |
66 | $qb->update('cospend_shares') |
67 | ->set('type', $qb->createNamedParameter('g', IQueryBuilder::PARAM_STR)) |
68 | ->where( |
69 | $qb->expr()->eq('isgroupshare', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT)) |
70 | ); |
71 | $qb->executeStatement(); |
72 | } |
73 | } |