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