Completed
Push — master ( b8f763...47a15d )
by Craig
14:22 queued 07:28
created

RoutesModuleInstaller::upgrade()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 35
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 14
nc 5
nop 1
dl 0
loc 35
rs 8.439
c 0
b 0
f 0
1
<?php
2
/**
3
 * Routes.
4
 *
5
 * @copyright Zikula contributors (Zikula)
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 * @author Zikula contributors <[email protected]>.
8
 * @link http://www.zikula.org
9
 * @link http://zikula.org
10
 * @version Generated by ModuleStudio 0.7.1 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule;
14
15
use Zikula\RoutesModule\Base\AbstractRoutesModuleInstaller;
16
17
/**
18
 * Installer implementation class.
19
 */
20
class RoutesModuleInstaller extends AbstractRoutesModuleInstaller
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function upgrade($oldVersion)
26
    {
27
        switch ($oldVersion) {
28
            case '1.0.0':
0 ignored issues
show
Coding Style introduced by
There must be a comment when fall-through is intentional in a non-empty case body
Loading history...
29
                // routes of system modules are not stored in database anymore
30
                $sql = '
31
                    DELETE FROM `zikula_routes_route`
32
                    WHERE `userRoute` = 0
33
                ';
34
                $this->entityManager->getConnection()->exec($sql);
35
36
                // update table to meet entity structure
37
                $this->schemaTool->update(['Zikula\RoutesModule\Entity\Historical\v110\RouteEntity']);
38
            case '1.0.1':
39
                // nothing
40
            case '1.1.0':
0 ignored issues
show
Coding Style introduced by
There must be a comment when fall-through is intentional in a non-empty case body
Loading history...
41
                // rename createdUserId field to createdBy_id
42
                $sql = '
43
                    ALTER TABLE `zikula_routes_route`
44
                    CHANGE `createdUserId` `createdBy_id` int(11) NOT NULL
45
                ';
46
                $this->entityManager->getConnection()->exec($sql);
47
48
                // rename updatedUserId field to updatedBy_id
49
                $sql = '
50
                    ALTER TABLE `zikula_routes_route`
51
                    CHANGE `updatedUserId` `updatedBy_id` int(11) NOT NULL
52
                ';
53
                $this->entityManager->getConnection()->exec($sql);
54
            case '1.1.1':
55
                // current version
56
        }
57
58
        return true;
59
    }
60
}
61