m180910_130202_craft3_upgrade   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 15 1
A safeDown() 0 4 1
1
<?php
2
3
namespace dukt\analytics\migrations;
4
5
use Craft;
6
use craft\db\Migration;
7
use dukt\analytics\fields\Report as ReportField;
8
use dukt\analytics\widgets\Realtime;
9
use dukt\analytics\widgets\Report as ReportWidget;
10
11
/**
12
 * m180910_130202_craft3_upgrade migration.
13
 */
14
class m180910_130202_craft3_upgrade extends Migration
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public function safeUp()
20
    {
21
        // Fields
22
        $this->update('{{%fields}}', [
23
            'type' => ReportField::class
24
        ], ['type' => 'Analytics_Report']);
25
26
        // Widgets
27
        $this->update('{{%widgets}}', [
28
            'type' => Realtime::class
29
        ], ['type' => 'Analytics_Realtime']);
30
31
        $this->update('{{%widgets}}', [
32
            'type' => ReportWidget::class
33
        ], ['type' => 'Analytics_Report']);
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function safeDown()
40
    {
41
        echo "m180910_130202_craft3_upgrade cannot be reverted.\n";
42
        return false;
43
    }
44
}
45