|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\RoutesModule; |
|
15
|
|
|
|
|
16
|
|
|
use Zikula\RoutesModule\Base\AbstractRoutesModuleInstaller; |
|
17
|
|
|
|
|
18
|
|
|
class RoutesModuleInstaller extends AbstractRoutesModuleInstaller |
|
19
|
|
|
{ |
|
20
|
|
|
public function upgrade(string $oldVersion): bool |
|
21
|
|
|
{ |
|
22
|
|
|
switch ($oldVersion) { |
|
23
|
|
|
case '1.1.0': // shipped with Core-1.4.3 |
|
24
|
|
|
// rename createdUserId field to createdBy_id |
|
25
|
|
|
$sql = ' |
|
26
|
|
|
ALTER TABLE `zikula_routes_route` |
|
27
|
|
|
CHANGE `createdUserId` `createdBy_id` int(11) NOT NULL |
|
28
|
|
|
'; |
|
29
|
|
|
$this->entityManager->getConnection()->exec($sql); |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
// rename updatedUserId field to updatedBy_id |
|
32
|
|
|
$sql = ' |
|
33
|
|
|
ALTER TABLE `zikula_routes_route` |
|
34
|
|
|
CHANGE `updatedUserId` `updatedBy_id` int(11) NOT NULL |
|
35
|
|
|
'; |
|
36
|
|
|
$this->entityManager->getConnection()->exec($sql); |
|
37
|
|
|
case '1.1.1': |
|
38
|
|
|
// drop obsolete fields |
|
39
|
|
|
$fieldNames = ['routeType', 'replacedRouteName', 'sort_group']; |
|
40
|
|
|
foreach ($fieldNames as $fieldName) { |
|
41
|
|
|
$sql = ' |
|
42
|
|
|
ALTER TABLE `zikula_routes_route` |
|
43
|
|
|
DROP COLUMN `' . $fieldName . '` |
|
44
|
|
|
'; |
|
45
|
|
|
$this->entityManager->getConnection()->exec($sql); |
|
46
|
|
|
} |
|
47
|
|
|
// add new field |
|
48
|
|
|
$sql = ' |
|
49
|
|
|
ALTER TABLE `zikula_routes_route` |
|
50
|
|
|
ADD `options` LONGTEXT NOT NULL |
|
51
|
|
|
COMMENT \'(DC2Type:array)\' AFTER `requirements` |
|
52
|
|
|
'; |
|
53
|
|
|
$this->entityManager->getConnection()->exec($sql); |
|
54
|
|
|
$sql = ' |
|
55
|
|
|
UPDATE `zikula_routes_route` |
|
56
|
|
|
SET `options` = \'a:0:{}\'; |
|
57
|
|
|
'; |
|
58
|
|
|
$this->entityManager->getConnection()->exec($sql); |
|
59
|
|
|
case '1.1.2': // shipped with Core-2.0.15 |
|
60
|
|
|
// nothing |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return true; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|