Passed
Push — develop ( f19af7...d856a2 )
by Andrew
04:19
created

m181013_122446_add_remote_ip   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 7 2
A safeDown() 0 4 1
1
<?php
2
3
namespace nystudio107\retour\migrations;
4
5
use Craft;
6
use craft\db\Migration;
7
8
/**
9
 * m181013_122446_add_remote_ip migration.
10
 */
11
class m181013_122446_add_remote_ip extends Migration
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function safeUp()
17
    {
18
        if (!$this->db->columnExists('{{%retour_stats}}', 'remoteIp')) {
19
            $this->addColumn(
20
                '{{%retour_stats}}',
21
                'remoteIp',
22
                $this->string(45)->after('referrerUrl')->defaultValue('')
23
            );
24
        }
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function safeDown()
31
    {
32
        echo "m181013_122446_add_remote_ip cannot be reverted.\n";
33
        return false;
34
    }
35
}
36