m200812_090059_add_default_column::safeUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m200812_090059_add_default_column
7
 */
8
class m200812_090059_add_default_column extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->addColumn(
16
            '{{%category}}',
17
            'default',
18
            $this->tinyInteger()->defaultValue(0)->after('status')
19
        );
20
21
        $this->addColumn(
22
            '{{%account}}',
23
            'default',
24
            $this->tinyInteger()->defaultValue(0)->after('credit_card_billing_day')
25
        );
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function safeDown()
32
    {
33
        echo "m200812_090059_add_default_column cannot be reverted.\n";
34
        $this->dropColumn('{{%category}}', 'default');
35
        $this->dropColumn('{{%account}}', 'default');
36
        return true;
37
    }
38
39
    /*
40
    // Use up()/down() to run migration code without a transaction.
41
    public function up()
42
    {
43
44
    }
45
46
    public function down()
47
    {
48
        echo "m200812_090059_add_default_column cannot be reverted.\n";
49
50
        return false;
51
    }
52
    */
53
}
54