m200818_021303_update_rules_table   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 8 1
A safeUp() 0 6 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m200818_021303_update_rules_table
7
 */
8
class m200818_021303_update_rules_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->renameColumn('{{%rule}}', 'then_account_id', 'then_from_account_id');
16
        $this->addColumn('{{%rule}}', 'then_to_account_id', $this->integer()->after('then_from_account_id'));
17
        $this->renameColumn('{{%rule}}', 'if_direction', 'then_transaction_type');
18
        $this->dropColumn('{{%rule}}', 'then_direction');
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function safeDown()
25
    {
26
        echo "m200818_021303_update_rules_table cannot be reverted.\n";
27
        $this->renameColumn('{{%rule}}', 'then_from_account_id', 'then_account_id');
28
        $this->dropColumn('{{%rule}}', 'then_to_account_id');
29
        $this->addColumn('{{%rule}}', 'then_direction', $this->tinyInteger()->after('then_transaction_type'));
30
        $this->renameColumn('{{%rule}}', 'then_transaction_type', 'if_direction');
31
        return true;
32
    }
33
34
    /*
35
    // Use up()/down() to run migration code without a transaction.
36
    public function up()
37
    {
38
39
    }
40
41
    public function down()
42
    {
43
        echo "m200818_021303_update_rules_table cannot be reverted.\n";
44
45
        return false;
46
    }
47
    */
48
}
49