m170324_000002_remove_old_widgets::safeUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace dukt\analytics\migrations;
4
5
use craft\db\Migration;
6
7
/**
8
 * The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
9
 */
10
class m170324_000002_remove_old_widgets extends Migration
11
{
12
    /**
13
     * Any migration code in here is wrapped inside of a transaction.
14
     *
15
     * @return bool
16
     */
17
    public function safeUp()
18
    {
19
        $this->delete('{{%widgets}}', ['type' => 'Analytics_Chart']);
20
        $this->delete('{{%widgets}}', ['type' => 'Analytics_Stats']);
21
        $this->delete('{{%widgets}}', ['type' => 'Analytics_Reports']);
22
23
        return true;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function safeDown()
30
    {
31
        echo "m170324_000002_remove_old_widgets cannot be reverted.\n";
32
33
        return false;
34
    }
35
}
36