Passed
Push — develop ( f8dfc2...cf33ee )
by Andrew
05:58
created

m190401_220828_longer_handles   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 4 1
A safeUp() 0 20 3
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace nystudio107\seomatic\migrations;
4
5
use craft\db\Migration;
6
7
/**
8
 * m190401_220828_longer_handles migration.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
10
class m190401_220828_longer_handles extends Migration
0 ignored issues
show
Coding Style introduced by
Class name must begin with a capital letter
Loading history...
Coding Style introduced by
Class name is not valid; consider M190401_220828_Longer_Handles instead
Loading history...
11
{
12
    /**
13
     * @inheritdoc
14
     */
15
    public function safeUp()
16
    {
17
        // https://github.com/yiisoft/yii2/issues/4492
18
        if ($this->db->getIsPgsql()) {
19
            $this->alterColumn(
20
                '{{%seomatic_metabundles}}',
21
                'sourceHandle',
22
                $this->string()
23
            );
24
            $this->alterColumn(
25
                '{{%seomatic_metabundles}}',
26
                'sourceHandle',
27
                "SET DEFAULT ''"
28
            );
29
        }
30
        if ($this->db->getIsMysql()) {
31
            $this->alterColumn(
32
                '{{%seomatic_metabundles}}',
33
                'sourceHandle',
34
                $this->string()->defaultValue('')
35
            );
36
        }
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function safeDown()
43
    {
44
        echo "m190401_220828_longer_handles cannot be reverted.\n";
45
        return false;
46
    }
47
}
48